Repository navigation
fix(codex): treat a revoked main session as needing sign-in and keep its last plan - #6496
vadymhimself wants to merge 1 commit into
Conversation
…its last plan ChatGPT revokes every session of an account whose plan changes (for example Pro to Free) and answers usage reads with 401 `token_invalidated`, while the access token's `exp` is still in the future. The main-account probe treated that 401 as transient, so the account kept `needsReauth: false`, its plan and quota went to null, and nothing told the operator to sign in again. - `token_invalidated` joins the terminal auth codes (one list, now shared with the CLI projection). - The quota-refresh diagnostic carries the terminal provider code (`quotaRefresh.code`), a fixed vocabulary, so a caller can say why. - A main row quarantined by this call's 401 reports `reauthReason: "unauthorized"` instead of `refresh_failed`. - A failed usage read keeps the last-known plan instead of nulling it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds allowlisted terminal-auth codes to quota-refresh errors. Main-account handling now preserves the last-known plan after a failed quota read and reports HTTP 401 reauthentication as ChangesMain account terminal-auth handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change marks a revoked main session as needing sign-in and keeps the last-known plan after a failed usage read. No merge-blocking issues were found. The author did not run the full test suite, so run it in CI before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change restricts reported authentication codes to a fixed vocabulary and preserves credential-identity checks before changing account state. No material security regression was established. Complete deployed access controls and behavior across process restarts were not verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. (3 skipped: 3 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. Hygiene✅ Deterministic PR hygiene checks passed. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Superseded by #6515, merged into Final-head required scoped CI passed: https://github.com/lidge-jun/opencodex/actions/runs/37132811309. The intermediate failed diagnostic-count assertion and subsequent cause-attribution regression were corrected with their intended contracts documented. This is delivery to dev; live revoked-account and final integrated release evidence are not implied. Thank you for the original fix. |
Summary
When ChatGPT changes an account's plan (seen live on a Pro to Free downgrade), it revokes every session of that account. Usage reads then answer:
The access token's
expis still in the future. The main-account probe only treats a 401 from a verifiably live token as terminal when the body code is inMAIN_TERMINAL_AUTH_CODES, andtoken_invalidatedwas not in it. So the probe treated a dead session as a transient blip. The account list then showedneedsReauth: false,plan: nullandquota: null, and nothing told the operator to sign in again.token_invalidatedjoins the terminal auth codes. The list moves toCODEX_TERMINAL_AUTH_CODESinsrc/codex/quota-refresh-outcome.ts, andMAIN_TERMINAL_AUTH_CODESis derived from it.quotaRefreshdiagnostic gains an optionalcode, taken only from that fixed vocabulary, so a caller can say why. The CLI projection copies it the same way.reauthReason: "unauthorized"instead ofrefresh_failed.A bare 401 from a live token is still transient (#1932). Only the named code changes.
Verification
bun run typecheck: clean.tests/codex-integration/codex-main-token-invalidated.test.ts: 1/1 pass. It fails withsrc/reverted todev.codex-auth-api345/345,main-account-hard-lock-recovery68/68,cli-account153/153. Three exact-shape assertions in the first two files gain the newcodefield, which is the intended diagnostic change.tests/codex,tests/cliandtests/codex-integrationrun as a batch againstdev: no failure names added.bun scripts/file-size-ratchet.ts,bun run structure:check,bun run privacy:scanandtests/test-layout.test.ts: all pass.needsReauth: true, plan: "pro", quotaRefresh: {status: "http_error", httpStatus: 401, code: "token_invalidated"}.Not run: the full
bun run test.Checklist
structure/dashboard-and-usage.md,reference/configuration/server.md).codeis a fixed enum, and no provider body text is forwarded.🤖 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
New Features
Documentation