Skip to content

Fix OAuth refresh redirects and credential-store races - #1054

Merged
mcncl merged 2 commits into
mainfrom
fix/refresh_transport_safety
Oct 21, 2026
Merged

mcncl merged 2 commits into
mainfrom
fix/refresh_transport_safety

Conversation

@mcncl

@mcncl mcncl commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Description

A 401 from a redirected download can cause the CLI to retry with its API token after Go stripped authorization. Concurrent refreshes also read mutable credential-store state outside the refresh lock.

Changes

  • Refresh only Bearer-authenticated requests to configured REST or GraphQL API origins.
  • Preserve same-origin redirect authentication without replacing other authentication identities. Match both dialing and HTTP wire authorities, including numeric ports and IDNA hostnames.
  • Serialize credential-store reads and writes, retaining one refresh for concurrent 401s.

This does not change the SDK's existing redirect-header forwarding.

Testing

  • Tests have run locally (go test ./..., with inherited credentials removed).
  • Code is formatted (mise run format).
  • Lint passes with zero issues (mise run lint).
  • HTTP and factory tests pass under -race; the concurrent-refresh case passes 20 repetitions.
  • Synthetic redirect regressions cover REST, GraphQL POST replay, multi-hop identity changes, and a loopback HTTP proxy.

Keep refresh retries within authenticated configured API origins so a
401 from a redirected download cannot reintroduce API credentials.
Preserve legitimate same-origin REST and GraphQL redirects without
replacing other authentication identities.

Match origins consistently across numeric ports, DNS lookup and HTTP
wire authorities. Serialize all refresh credential-store access so
concurrent 401s share one token exchange without racing on backend
selection.
@mcncl
mcncl requested review from a team as code owners October 19, 2026 10:26

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actionable findings from this pass. This changes credential forwarding and OAuth refresh eligibility across redirects (L3), so I’m leaving approval to a human.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 42406, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

About buildsworth

Model: gpt-6.1-sol with xhigh thinking.

How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.

Risk labels (how buildsworth classifies risk) — buildsworth classifies risk itself from the diff. Unless repository policy already allows L2 approval, grant it by mentioning @buildsworth-bk (see approval ceiling and L2 approval grant):

  • L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
  • L2 — Standard risk (new UI, additive API fields, refactors). Approved only when repository policy or a verified grant allows it; otherwise comment-only.
  • L3 — High risk (auth, migrations, payments, secrets, perf-critical pipeline paths). Human approval required unless repository policy explicitly allows L3 approval; per-PR grants cannot allow it.

@mcncl
mcncl enabled auto-merge (squash) October 21, 2026 10:36
Keep both direct dependency declarations and factory test imports.
Preserve refresh safety checks alongside debug and streaming updates.

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No actionable findings from this pass. This changes API-token forwarding across redirects and OAuth refresh eligibility (L3), so human approval is required.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 43588, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@mcncl
mcncl merged commit 0329295 into main Oct 21, 2026
2 checks passed
@mcncl
mcncl deleted the fix/refresh_transport_safety branch October 21, 2026 10:45
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.

2 participants