Repository navigation
fix(fleet): parse the personal token on the cache-daemon path too - #12500
Merged
Merged
Conversation
The gh cache daemon's personal op returns the resolved hosts.yml secret itself (it is a dumb secret cache for that op), but FleetTokenProvider used the daemon response as a finished token and only parsed the in-process copy. Whenever a daemon answered, gh got the whole 183-char hosts.yml as GH_TOKEN and refused it client-side: net/http: invalid header field value for "Authorization". Reads masked it (they fail over on any failure); writes surfaced it, since they repeat only on pre-execution refusals. Resolve the secret through via() on both paths and parse the oauth_token out of whichever copy answered, in one place (personal_token()). Document the wire-contract asymmetry in gh_cache.rs and add the regression test personal_token_is_the_parsed_token_not_the_secret.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 22, 2026
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.
What broke
Every
fleet ghwrite failed client-side while reads looked fine:Root cause
The cache daemon's
personalop returns the resolved secret itself — the wholegithub-cli.hosts-ymlfile — in the response'stokenfield. That is by design: the daemon is a dumb secret cache for this op and never learns which secret "personal" means (the request carries the secret name for exactly this reason).FleetTokenProvider::token_forbroke the contract: when a daemon answered it returnedresponse_token()directly as the token, and only the in-process fallback closure ranparse_hosts_yml_token. So with the (now always-on) local daemon up, gh received the 183-char multi-line hosts.yml asGH_TOKENand refused it as an Authorization header value.Reads masked it completely: a read fails over to an App installation token on any failure, so attempt 1 (personal) died and attempt 2 succeeded. Writes repeat only on pre-execution refusals (the #8887 retry-safety contract), and a client-side header error is not one — so every write surfaced the failure.
FLEET_GH_RAW=1worked because it injects no token at all.Shape evidence (lengths/classes only, never values): injected
GH_TOKENvia the daemon was 183 chars containing newlines and colons (a YAML file); via--no-cacheit was the clean 40-chargho_token. Bisected with a stubFLEET_GH_BINreporting the injected token's shape, plusFLEET_GH_BIN=/usr/bin/ghruns ruling the PATH shim in/out.Fix
gh.rs: resolve the hosts.yml secret throughvia()(daemon or in-process), then parse theoauth_tokenout of whichever copy answered — one convergence point,personal_token().gh_cache.rs: document the wire-contract asymmetry atrequest()so the next reader does not reintroduce it.personal_token_is_the_parsed_token_not_the_secret: the value reachingGH_TOKENis the parsed, header-safe token, never the multi-line secret; a secret withoutoauth_tokenerrors by name.Verification
cargo test -p fleet(1.99 toolchain): 70 unit + 9 integration tests pass, including the new regression test and all pre-existinggh::/gh_cache::tests.FLEET_GH_BINpinned to the pristine gh exactly as the PATH shim pins it:POST /repos/developing-today/code/issues/12492/reactionssucceeds on attempt 1 under personal (before: the header error above); reads still ~1.6s.~/tools/fleetkeeps the defect until a build from this branch (or main after merge) is deployed; until thenFLEET_GH_RAW=1remains the workaround for writes.Related documentation:
doc/agents/gh-cache-daemon.mdgained a section on this break (thepersonalcontract, the shape-based diagnostic, and the direct-invocation shim-nesting wart with the same symptom family).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.