Skip to content

fix(fleet): parse the personal token on the cache-daemon path too - #12500

Merged
dezren39 merged 1 commit into
mainfrom
xaltha/fleet-gh-personal-daemon-fix
Nov 22, 2026
Merged

dezren39 merged 1 commit into
mainfrom
xaltha/fleet-gh-personal-daemon-fix

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What broke

Every fleet gh write failed client-side while reads looked fine:

Post "https://api.github.com/...": net/http: invalid header field value for "Authorization"

Root cause

The cache daemon's personal op returns the resolved secret itself — the whole github-cli.hosts-yml file — in the response's token field. 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_for broke the contract: when a daemon answered it returned response_token() directly as the token, and only the in-process fallback closure ran parse_hosts_yml_token. So with the (now always-on) local daemon up, gh received the 183-char multi-line hosts.yml as GH_TOKEN and 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=1 worked because it injects no token at all.

Shape evidence (lengths/classes only, never values): injected GH_TOKEN via the daemon was 183 chars containing newlines and colons (a YAML file); via --no-cache it was the clean 40-char gho_ token. Bisected with a stub FLEET_GH_BIN reporting the injected token's shape, plus FLEET_GH_BIN=/usr/bin/gh runs ruling the PATH shim in/out.

Fix

  • gh.rs: resolve the hosts.yml secret through via() (daemon or in-process), then parse the oauth_token out of whichever copy answered — one convergence point, personal_token().
  • gh_cache.rs: document the wire-contract asymmetry at request() so the next reader does not reintroduce it.
  • Regression test personal_token_is_the_parsed_token_not_the_secret: the value reaching GH_TOKEN is the parsed, header-safe token, never the multi-line secret; a secret without oauth_token errors by name.

Verification

  • cargo test -p fleet (1.99 toolchain): 70 unit + 9 integration tests pass, including the new regression test and all pre-existing gh::/gh_cache:: tests.
  • End-to-end with a locally built binary against the live local daemon, normal (non-raw) path, FLEET_GH_BIN pinned to the pristine gh exactly as the PATH shim pins it: POST /repos/developing-today/code/issues/12492/reactions succeeds on attempt 1 under personal (before: the header error above); reads still ~1.6s.
  • Note: the installed ~/tools/fleet keeps the defect until a build from this branch (or main after merge) is deployed; until then FLEET_GH_RAW=1 remains the workaround for writes.

Related documentation: doc/agents/gh-cache-daemon.md gained a section on this break (the personal contract, the shape-based diagnostic, and the direct-invocation shim-nesting wart with the same symptom family).


Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 10:38
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71029d9f-d258-450a-a346-cd0fbb2ef3a4
Commits

Reviewing files that changed from the base of the PR and between d4a004a and 44f837c.

Files selected for processing: 2

  • pkgs/fleet/crates/fleet/src/gh.rs
  • pkgs/fleet/crates/fleet/src/gh_cache.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T10:40:11.888501Z 44f837c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant