You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(anthropic): refuse redirects on the usage probe and reset-grant requests - #8758
The OAuth profile probe (src/oauth/anthropic-identity.ts) already passes redirect: "error", and so do the other vendor quota probes in src/providers/quota/. Three other Anthropic requests that send the OAuth bearer still followed redirects:
the usage probe in src/providers/claude-cli-usage.ts;
the reset-grant status/profile read (getAccountJson) in src/providers/anthropic-reset-grants.ts;
the reset-grant claim POST in the same file.
Following a redirect could send the bearer to another host. For the claim, a 307/308 would also re-post the claim body there.
This change sets redirect: "error" on all three requests. A refused redirect throws, so the existing catches handle it:
the usage probe behaves exactly as it does today for a thrown fetch;
the read reports upstream;
the claim reports the existing unknown outcome. It is never treated as settled.
I updated the owning structure docs (structure/gui-and-management-api.md and structure/providers/claude-cli-replay.md).
This is carried over from the vadymhimself fork (1f93f91), where it covered the usage and profile probes. The reset-grant requests are new on dev since then.
Verification
All commands used the pinned Bun 1.4.4 with an isolated HOME. Latest validation: head 052e91f32f after merging upstream/dev on 2026-11-17. The latest affected suite passed 54 tests; the 150-test combined run below is the original validation.
bun test tests/providers/provider-anthropic-usage-windows.test.ts: 54 pass, 0 fail. With the src/ change reverted, the new test fails (53 pass, 1 fail).
bun test on that file plus tests/cli/cli-account-policy.test.ts and tests/cli/cli-anthropic2-account.test.ts: 150 pass, 0 fail.
bun scripts/test.ts --changed=upstream/dev: 45,915 pass, 4 fail. The four failures fail the same way on dev and on my earlier PRs:
retained sync and serve-options
connected-client runtime probe scope
end-to-end Home <-> compiled ocx-child lifecycle ×2, where the local Child build fails at cc with exit 69
bun run typecheck, bun run structure:check and bun run privacy:scan all pass.
There is no wire change for a non-redirect response, so I did not re-run a live measurement.
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed.
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
Requests to Anthropic’s usage and reset-grant endpoints now reject redirects rather than following them. If a reset-grant claim is redirected, its outcome is reported as unknown.
Documentation
Clarified redirect handling for usage checks and reset-grant requests.
…equests
The OAuth profile probe already passes redirect: "error", but the usage probe
in claude-cli-usage.ts and the reset-grant status read and claim POST in
anthropic-reset-grants.ts followed redirects. A redirect must never carry the
OAuth bearer, or a 307/308 re-post of the claim, to another host. A refused
claim redirect lands in the existing unknown-outcome catch.
Carried over from the vadymhimself fork (1f93f91).
Co-Authored-By: Claude Code <[email protected]>
Reviewing files that changed from the base of the PR and between 4bb6e6e and 052e91f.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Anthropic usage and reset-grant requests now reject redirects. A refused redirect during a reset-grant claim produces AnthropicResetGrantUnknownOutcome. A test checks the redirect option on all three requests, and the documentation describes the behavior.
Changes: Anthropic redirect handling
Layer / File(s)
Summary
Reject redirects on Anthropic requests src/providers/claude-cli-usage.ts, src/providers/anthropic-reset-grants.ts, tests/providers/provider-anthropic-usage-windows.test.ts, structure/providers/claude-cli-replay.md, structure/gui-and-management-api.md
The usage probe and both reset-grant requests set redirect: "error". If a claim redirect is refused, the existing catch throws AnthropicResetGrantUnknownOutcome. The test checks the redirect option for all three requests, and the documentation describes the behavior.
This change stops Anthropic usage and reset-grant requests from following redirects, which keeps the bearer token from being forwarded to another host. Non-redirect behavior is unchanged. The change has a focused test and updated documentation, and no merge-blocking risk is apparent.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(anthropic): refuse redirects on the usage probe and reset-grant requests" names the main change: the Anthropic usage probe and reset-grant requests now use redirect: "error". The raw su…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title "fix(anthropic): refuse redirects on the usage probe and reset-grant requests" names the main change: the Anthropic usage probe and reset-grant requests now use redirect: "error". The raw summary confirms the changes in src/providers/claude-cli-usage.ts and src/providers/anthropic-reset-grants.ts, plus matching docs and tests. The title is specific, concise, and free of file lists or vague terms, so it matches the changeset.
Finishing Touches
Generate unit tests (beta)
Create a new PR
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
all PR quality gates passed; the review readiness checklist is complete.
Review readiness checklist
✅ Required local validation passed; commands, results, and any full-suite exception are documented.
✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
✅ I resolved all correct Codex and CodeRabbit findings.
✅ My PR is ready for review.
✅ 4/4 boxes ticked.
This pull request has been marked Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers notified: @lidge-jun@Ingwannu
Thank you. This change was carried, with your authorship kept as a Co-authored-by trailer, in #8868, which is now merged into dev as bfdb2bc (2026-11-17 triage round). Closing as superseded; see #8868 for any follow-up changes made during review.
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
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.
Summary
src/oauth/anthropic-identity.ts) already passesredirect: "error", and so do the other vendor quota probes insrc/providers/quota/. Three other Anthropic requests that send the OAuth bearer still followed redirects:src/providers/claude-cli-usage.ts;getAccountJson) insrc/providers/anthropic-reset-grants.ts;redirect: "error"on all three requests. A refused redirect throws, so the existing catches handle it:upstream;structure/gui-and-management-api.mdandstructure/providers/claude-cli-replay.md).devsince then.Verification
All commands used the pinned Bun 1.4.4 with an isolated
HOME. Latest validation: head052e91f32fafter mergingupstream/devon 2026-11-17. The latest affected suite passed 54 tests; the 150-test combined run below is the original validation.bun test tests/providers/provider-anthropic-usage-windows.test.ts: 54 pass, 0 fail. With thesrc/change reverted, the new test fails (53 pass, 1 fail).bun teston that file plustests/cli/cli-account-policy.test.tsandtests/cli/cli-anthropic2-account.test.ts: 150 pass, 0 fail.bun scripts/test.ts --changed=upstream/dev: 45,915 pass, 4 fail. The four failures fail the same way ondevand on my earlier PRs:retained sync and serve-optionsconnected-client runtime probe scopeend-to-end Home <-> compiled ocx-child lifecycle×2, where the local Child build fails atccwith exit 69bun run typecheck,bun run structure:checkandbun run privacy:scanall pass.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
🤖 Generated with Claude Code
Summary by CodeRabbit