feat: add agent header support#1158
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds ChangesAgent trace header propagation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@d79bf753b72ef580afe5988d214467b8373fefc6🧩 Skill updatenpx skills add larksuite/cli#feat/agent_header -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1158 +/- ##
==========================================
+ Coverage 68.71% 68.78% +0.07%
==========================================
Files 627 628 +1
Lines 58451 58680 +229
==========================================
+ Hits 40163 40363 +200
- Misses 14999 15021 +22
- Partials 3289 3296 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/cmdutil/secheader.go`:
- Around line 62-64: Reject/control-sanitize AGENT_TRACE before setting
X-Agent-Trace: read the value from AgentTraceValue(), trim surrounding
whitespace, and only call h.Set(HeaderAgentTrace, v) if the trimmed value is
non-empty and contains no CR or LF (e.g., check strings.ContainsAny(v, "\r\n")
or use unicode.IsControl) to prevent injection/malformed headers; reference
AgentTraceValue(), HeaderAgentTrace and the h.Set call when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5896bb05-fb3a-4161-a953-408f46cf41e3
📒 Files selected for processing (3)
internal/cmdutil/secheader.gointernal/cmdutil/secheader_test.gointernal/envvars/envvars.go
|
Actionable comments posted: 0 |
* feat: add agent header support
Summary
Add support for the
AGENT_TRACEenvironment variable: when set, its value is automatically injected as theX-Agent-Traceheader on every outgoing HTTP request (both direct and SDK paths).Changes
CliAgentTrace = "AGENT_TRACE"tointernal/envvars/envvars.goHeaderAgentTrace = "X-Agent-Trace"constant tointernal/cmdutil/secheader.goAgentTraceValue()function that reads theAGENT_TRACEenv varBaseSecurityHeaders()to conditionally includeX-Agent-Tracewhen the env var is non-emptyTest Plan
TestAgentTraceValue_EmptyWhenEnvUnset,TestAgentTraceValue_ReturnsEnvValue,TestBaseSecurityHeaders_NoAgentTraceHeaderWhenEnvUnset,TestBaseSecurityHeaders_IncludesAgentTraceHeaderWhenEnvSet)lark-cli <domain> <command>flow works as expectedRelated Issues
Summary by CodeRabbit