fix(codex): preserve permission errors across authenticated requests - #3466
Conversation
Keep HTTP 403 terminal while retaining 401 authentication recovery. Consolidate OAuth and PAT transport handling. Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 7, 2026, 2:45 AM ET / 06:45 UTC. ClawSweeper reviewWhat this changesShares Codex authenticated-request error handling across OAuth and personal access tokens, preserving HTTP 403 permission errors while retaining HTTP 401 recovery. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, bounded fix: current main and v0.56.7 still classify 403 as expired authentication. No introduced correctness defect was found. The broader credential-renewal PR remains distinct, and repository policy protects this owner-authored PR from automatic closure. Priority: P2 Review scores
Verification
How this fits togetherCodexBar fetches account usage and credit information through authenticated provider requests. Their error classification determines whether the refresh pipeline reports a failure or tries CLI recovery. flowchart TD
A[OAuth or personal access token] --> B[Authenticated API request]
B --> C{HTTP response}
C -->|Success| D[Decode usage or credits]
C -->|401| E[Authentication recovery policy]
C -->|403 and other errors| F[Preserve API failure]
D --> G[Usage display]
E --> H[Eligible CLI fallback]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the owner-proposed permission-error distinction, preserve 401 recovery and account isolation, and leave managed credential renewal to its separate proposal. Do we have a high-confidence way to reproduce the issue? Yes, from source: a 403 usage response on pinned main becomes unauthorized and permits eligible Auto fallback. The fixture pipeline exercises that path; this review did not run it. Is this the best way to solve the issue? Yes. Centralizing the repeated HTTP classification is a narrow repair that preserves request construction, decoding, cancellation, and existing 401 recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 02c073a22ab8. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
The changed Auto behavior is intentional: an API permission denial is terminal, whereas expired authentication (401) remains eligible for recovery. Falling back after 403 obscures the selected API/account failure. This distinction is documented and exercised through the actual fetcher-to-pipeline path, including the CLI sentinel and 401 controls. The review found no introduced correctness or authority defect; the reported behavior change is the fix rather than an unresolved implementation issue. Broader credential renewal remains in #3379. |
…teipete#3466) HTTP 403 from Codex OAuth and PAT endpoints was treated as expired authentication. In Auto mode this could trigger CLI recovery for a permission denial. Preserve the status and response body as a terminal server error; HTTP 401 retains authentication recovery. Share request status, network-error, and cancellation handling across usage, reset-credit, spend-control, and PAT requests. Requests and decoding contracts remain unchanged. Production code decreases by 64 lines. The actual fetcher-to-pipeline regression failed before the change, including Auto selecting the CLI fallback sentinel. All 93 focused tests across five suites pass, covering OAuth/PAT endpoints, 401 controls, and terminal 403 behavior. `make check` and the full `make test` suite pass (1,028 selections across 86 groups; no retries). Independent review found no actionable P0–P2 findings. Tests use synthetic responses; no live account access is claimed. This extracts the status distinction discussed in steipete#3379; the broader managed credential renewal work remains open. Thanks @Yuxin-Qiao for that work. Changelog and OAuth documentation are updated. Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
…teipete#3466) HTTP 403 from Codex OAuth and PAT endpoints was treated as expired authentication. In Auto mode this could trigger CLI recovery for a permission denial. Preserve the status and response body as a terminal server error; HTTP 401 retains authentication recovery. Share request status, network-error, and cancellation handling across usage, reset-credit, spend-control, and PAT requests. Requests and decoding contracts remain unchanged. Production code decreases by 64 lines. The actual fetcher-to-pipeline regression failed before the change, including Auto selecting the CLI fallback sentinel. All 93 focused tests across five suites pass, covering OAuth/PAT endpoints, 401 controls, and terminal 403 behavior. `make check` and the full `make test` suite pass (1,028 selections across 86 groups; no retries). Independent review found no actionable P0–P2 findings. Tests use synthetic responses; no live account access is claimed. This extracts the status distinction discussed in steipete#3379; the broader managed credential renewal work remains open. Thanks @Yuxin-Qiao for that work. Changelog and OAuth documentation are updated. Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
HTTP 403 from Codex OAuth and PAT endpoints was treated as expired authentication. In Auto mode this could trigger CLI recovery for a permission denial. Preserve the status and response body as a terminal server error; HTTP 401 retains authentication recovery.
Share request status, network-error, and cancellation handling across usage, reset-credit, spend-control, and PAT requests. Requests and decoding contracts remain unchanged. Production code decreases by 64 lines.
The actual fetcher-to-pipeline regression failed before the change, including Auto selecting the CLI fallback sentinel. All 93 focused tests across five suites pass, covering OAuth/PAT endpoints, 401 controls, and terminal 403 behavior.
make checkand the fullmake testsuite pass (1,028 selections across 86 groups; no retries). Independent review found no actionable P0–P2 findings. Tests use synthetic responses; no live account access is claimed.This extracts the status distinction discussed in #3379; the broader managed credential renewal work remains open. Thanks @Yuxin-Qiao for that work. Changelog and OAuth documentation are updated.