Repository navigation
fix: report failing OAuth stage and request ID when ChatGPT sign-in returns an HTTP error - #206868
zsicheng0214 wants to merge 3 commits into
Conversation
…eturns an HTTP error
|
🦞👀 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. What this changesThis PR adds OAuth stage labels and bounded upstream request identifiers to ChatGPT authentication errors. Example: ChatGPT token exchange returns HTTP 403 with x-request-id=req_403_trace_01.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Blocked before merge - 1 item remains This PR provides useful diagnostics that current main lacks, with no actionable correctness findings; required CI has not run because GitHub reports action_required. Reviewed head: Before merge
FindingsNone. Agent review detailsHow this fits togetherThe OpenAI plugin exchanges and refreshes SIWC credentials and fetches signing keys; its response handler turns upstream HTTP failures into errors consumed by login and model-probe entry points. flowchart TD
A[CLI or Gateway] --> B[OpenAI provider plugin]
B --> C[SIWC OAuth runtime]
C --> D[Guarded HTTP transport]
D --> E[OpenAI OAuth endpoints]
E --> F[Bounded error diagnostics]
F --> A
Technical reviewBest possible solution: Land the focused diagnostics after required CI passes, while keeping the linked sign-in failure open for diagnosis. Do we have a high-confidence way to reproduce the issue? Current-main source directly establishes the missing stage and request-ID diagnostics; contributor evidence demonstrates the changed refresh error through the CLI, but the linked account's HTTP 403 cause remains unverified. Is this the best way to solve the issue? The patch enriches errors at the existing provider-owned response boundary without changing requests, credential storage, or refresh recovery policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 848732ff9f98. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +55, Tests +68. Total +123 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed November 28, 2026, 10:38 PM ET / November 29, 2026, 03:38 UTC (Revision 5). |
|
Addressed the P2 finding and updated the PR evidence for head
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Addressed the P2 typecheck finding in
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Added live unmocked @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Added live, unmocked shipped CLI proof on @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Related: #204662
What Problem This Solves
When Sign in with ChatGPT (
models.authLogin/openclaw models auth login --provider openai --method siwc) or a subsequent token refresh fails with a server-side HTTP error such asHTTP 403, OpenClaw reports onlyChatGPT authentication request failed (HTTP 403). Retry sign-in later.(for login/JWKS) orChatGPT token-sharing refresh failed (403): provider_error(for refresh) without saying which server-side OAuth stage failed or surfacing any upstream request identifier. That leaves users and maintainers unable to tell which endpoint rejected the request or correlate the failure with upstream support logs.User Impact
When a ChatGPT sign-in, JWKS fetch, or token refresh request returns a non-2xx HTTP status (other than
invalid_grant, whose reconnect message is preserved unchanged), the error message now includes bounded, sanitized diagnostics:ChatGPT authentication request failed (HTTP 403). Retry sign-in later.ChatGPT authentication request failed during token exchange (HTTP 403, access_denied, x-request-id=req_403_trace_01). Retry sign-in later.jwks.json) fetch HTTP 403:ChatGPT authentication request failed (HTTP 403). Retry sign-in later.ChatGPT authentication request failed during signing key fetch (HTTP 403, cf-ray=8f1234567890-SJC). Retry sign-in later.oauthRefreshOutcomeandinvalid_granthandling):ChatGPT token-sharing refresh failed (403): provider_errorChatGPT token-sharing refresh failed (403): provider_error (x-request-id=req_403_trace_01)Raw provider response bodies and credentials are never exposed, and malformed request-ID headers containing whitespace or control characters are ignored. No user action or migration is required.
Why This Change Was Made
requestJsoninextensions/openai/token-sharing-oauth.runtime.tsalready enforces bounded response reading and intentionally omits provider response bodies to prevent credential leakage. Passing an explicitOAuthRequestStagelabel from its three call sites (token exchange,token refresh,signing key fetch), enriching both therefresh_tokenerror branch (without alteringoauthRefreshOutcomeorinvalid_grantrecovery semantics) and the general non-2xx login/JWKS branch, and extracting only strictly validated single-token identifiers (^[A-Za-z0-9_.:/-]{1,128}$) closes the diagnostic gap noted in#204662across all three OAuth stages.Evidence
1. Live Shipped CLI End-to-End Verification Against Real
auth.openai.com(Reviewed Head516e94036, Nodev24.22.3, Zero HTTP Mocks)Shipped CLI command
openclaw models status --probe --probe-provider openai --probe-timeout 45000 --json(modelsStatusCommand) with an expiredsiwcOAuth profile in an isolated state directory, hitting realhttps://auth.openai.com/api/accounts/oauth/tokenand surfacing the live upstreamx-request-iddirectly in the user-facing CLI probe JSON output (temp paths and UUID redacted):{ "defaultModel": "openai/gpt-5.4", "auth": { "providersWithOAuth": ["openai (1)"], "probes": { "durationMs": 32820, "totalTargets": 1, "options": { "provider": "openai", "timeoutMs": 45000 }, "results": [ { "provider": "openai", "model": "openai/gpt-5.4", "profileId": "openai:default", "label": "openai:default", "source": "profile", "mode": "oauth", "status": "auth", "error": "Isolated completion preparation failed: Auth lookup failed for provider \"openai\": OAuth token refresh failed for openai: ChatGPT token-sharing refresh failed (400): invalid_client (x-request-id=<redacted-uuid>). Please try again or re-authenticate." } ] } } }Shipped CLI command
openclaw models auth login --provider openai --method siwc(modelsAuthLoginCommand) with real loopback OAuth callback server against realhttps://auth.openai.com/api/accounts/oauth/token, confirminginvalid_grantreconnect semantics remain unchanged:Production OAuth runtime + real loopback callback server (
extensions/openai/token-sharing-oauth.runtime.test.ts) covering all three non-2xx stages (token exchange HTTP 403 +x-request-id, signing key fetch HTTP 403 +cf-ray, token refresh HTTP 403 +x-request-id+ preservedoauthRefreshOutcome, and malformed request-ID header rejection):2. Base Failure, Typecheck, Lint & Format (
516e94036)origin/main) fails on all 4 new regression tests (4 failed | 35 skipped (39)).pnpm exec tsgo --noEmit --project tsconfig.json— 0 errors.pnpm exec oxlint extensions/openai/token-sharing-oauth.runtime.ts extensions/openai/token-sharing-oauth.runtime.test.ts—Found 0 warnings and 0 errors.pnpm exec oxfmt --check extensions/openai/token-sharing-oauth.runtime.ts extensions/openai/token-sharing-oauth.runtime.test.ts—All matched files use the correct format.