Repository navigation
fix(usage): seal a credential-rotation attempt with the status it answered - #7321
vadymhimself wants to merge 1 commit into
Conversation
…wered When an account rotation splits the attempt row, the sealed attempt with no recorded status fell back to 401 for key-401, 429 for any *-429 kind, and 502 for everything else. An `oauth-account-403` rotation was therefore logged as a 502 server error, and `oauth-401` / `oauth-account-402` likewise, although the recovery kind names the status the account actually returned. Map those kinds to 401, 403 and 402 too. A status already recorded on the attempt still wins. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Intake/scoped review at The sealed attempt now maps oauth-401, oauth-account-402 and oauth-account-403 to the actual account refusal status, while an already-recorded status remains authoritative. Keep credential identity and recovery-kind attribution separate from this status correction. The new parameterized cases cover the three previously misclassified values. Current-head functional workflows are awaiting fork approval; that is pending execution, not a passing test result. No local suite was run for this branch in this intake. No workflow approval, new scan, live configuration change or merge was performed. Required review/readiness gates remain in force. |
Summary
noteProviderAttemptSendwith a changed account label or account-qualified provider), the sealed attempt that has no recorded status takes one from the recovery kind. That mapping covered onlykey-401-> 401 and*-429-> 429; every other kind fell to 502. An Anthropic/OAuthoauth-account-403rotation was therefore logged as a 502 server error, and the same foroauth-401andoauth-account-402, although each kind names the status the account actually returned.oauth-401-> 401,oauth-account-403-> 403 andoauth-account-402-> 402. A status already recorded on the attempt still wins, and the failure cause (already derived from the recovery kind) is unchanged.src/server/request-log.ts; routing, cooldowns and the client response are unchanged.Verification
an account rotation after %s seals the first row with the status it answeredintests/usage/key-attribution.test.ts, run before the src change:bun test tests/usage/key-attribution.test.ts-> 17 pass, 3 fail (Expected "status": 403 / 401 / 402,Received "status": 502). After the change: 20 pass, 0 fail.bun x tsc --noEmit-> exit 0.bun scripts/file-size-ratchet.ts-> passed.bun run test:changed(Bun 1.4.3 viaOCX_TEST_RUNNER_BUN) -> 16947 pass, 34 skip, 1 fail across 692 files. The single failure,tests/cli/cli-connect-readiness.test.ts"a rejected preferred runtime falls back without rewriting the saved selection", fails identically on an unmodifiedupstream/dev8640c2f checkout on this machine (local-environment dependent) and is unrelated to the usage log.bun run testwas not run locally:test:changedalready covered 692 files through the changed module's import graph; the remainder is left to CI.Checklist
Source: carried from the vadymhimself fork build (commit ef65d20, status-mapping half only), re-authored against current
dev. The fork's other half, splitting the row on a same-accountoauth-401replay, is deliberately not included: it contradictstests/server/server-xai-oauth-401-replay.test.ts(sendCount2).🤖 Generated with Claude Code
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.
Summary by CodeRabbit