Repository navigation
Add a hidden, repeatable --header flag for API requests - #382
Merged
Merged
Conversation
Integrations such as the sandbox GitHub Action need to say who they are, so that usage can be counted from the API's metrics rather than from a label on every sandbox. --header "Name: value" adds a header to every API request, and may be given more than once; a repeated name keeps every value, as HTTP allows. The headers the CLI owns cannot be set this way: Authorization, Signadot-Api-Key, Signadot-Cluster-Token, User-Agent, Cookie and the framing headers. Names must be RFC 9110 tokens and values one line. Only when --header is given does the SDK get an http.Client of the CLI's own; the SDK then skips its User-Agent wrapper, so the new transport sets User-Agent too. Without the flag every request is exactly as before. Hidden while its use is worked out. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
davixcky
requested review from
daniel-de-vera,
joehorsnell and
scott-cotton
September 30, 2026 13:41
Member
|
Looks overall good to me. Some findings would help make it more solid:
|
From review: - Validate names and values with httpguts, the checks Go's HTTP transport applies, so a value with NUL, DEL or any other control character is refused up front instead of failing every request with 'invalid header field value'. - Refuse Accept and Accept-Encoding: the latter turned off the transport's transparent decompression, so the SDK was handed gzipped bytes, and the former went out beside the one the runtime sets. Also refuse the remaining hop-by-hop headers (Keep-Alive, Proxy-Connection, TE, Trailer, Upgrade, Expect). - The help and comments no longer say every API request: only clients built from API.GetBaseTransport carry the headers, and the local connect daemon and the remote MCP client build their own. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
Author
|
Thanks @scott-cotton, all three fixed in 5e3def0:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Why
We decided on 29 Sep (sprint planning, then David and Scott's huddle) to count sandbox GitHub Action usage from API metrics instead of putting a label on every sandbox. For that, the CLI needs a way for an integration to identify itself on its requests. Scott and David agreed on option C: a generic, repeatable
--headerflag, with no config-file surface.What
--header "Name: value", repeatable. A repeated name keeps every value in order, as HTTP allows.MarkHidden) while its use is worked out.Authorization,Proxy-Authorization,Signadot-Api-Key,Signadot-Cluster-Token,Cookie,User-Agent,Accept,Accept-Encoding,Content-Type,Content-Length, and the framing and hop-by-hop headers (Host,Transfer-Encoding,Connection,Keep-Alive,Proxy-Connection,TE,Trailer,Upgrade,Expect). Names and values are checked withhttpguts, the same checks Go's transport applies, so control characters are refused too. Bad input fails before any request, with a message naming the flag.http.Client. Only when--headeris given does the CLI pass one, whose transport adds the headers. The SDK skips its own User-Agent wrapper once it gets a custom client, so that transport also sets User-Agent. Without the flag, every request is exactly as before.Tests
TestParseHeaders: canonicalisation, trimming, repeated names, empty values.TestParseHeadersRefuses: malformed, an invalid name, CR/LF, NUL and DEL (a tab is allowed), and protected headers includingAccept,Accept-Encoding,TEandUpgrade.TestExtraHeadersReachTheAPI: a real SDK call to anhttptestserver, with and without the flag. The extra header arrives, andUser-AgentandSignadot-Api-Keyare intact.TestHeaderFlagIsHidden--helpdoesn't mention it, and--header "Authorization: x"is refused.internal/repoconfigfails locally in a git worktree, because go-git can't find HEAD there. That package is untouched here; CI will show whether it passes in a normal checkout.Still to agree
Signadot-Client-Contextwithintegration=…,integration-version=…is the proposal. The flag itself doesn't depend on that choice.🤖 Generated with Claude Code