fix(google): bound OAuth token error response reads#99605
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 6:44 PM ET / 22:44 UTC. Summary Reproducibility: yes. Current main and Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this focused diagnostic cap after exact-head checks are acceptable, while keeping JSON parser hardening in the separate Google OAuth PR unless maintainers choose to fold the changes together. Do we have a high-confidence way to reproduce the issue? Yes. Current main and Is this the best way to solve the issue? Yes. Replacing the Google plugin's non-OK diagnostic read with the existing shared bounded reader is the narrow owner-boundary fix; broader JSON parser hardening should remain coordinated through the separate open PR. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 219f27a5ec6b. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Maintainer proof for clean exact head
Proof boundary: Google controls live error-body size, so the live call proves the production endpoint/error path while the focused regression proves oversized-body truncation. The shared Google transport already imposed a 16 MiB response cap; this change specifically prevents materializing more than 8 KiB as diagnostic text. The local prepared tree and pushed PR tree are identical ( |
456cf8b to
cfc513c
Compare
|
Merged via squash.
|
* fix(google): bound OAuth token error response reads * test(google): consolidate OAuth error cases --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
What Problem This Solves
Google OAuth token grant failures previously used
response.text()on non-OK responses. That fully consumes an external HTTP response body before throwing, so a malformed upstream/proxy/provider failure body could force OpenClaw to buffer more diagnostic text than needed.User Impact
Users who hit Google Gemini CLI OAuth exchange or refresh failures still receive the provider diagnostic prefix, but the failure path no longer depends on buffering an unbounded response body.
Origin / follow-up
Follows #97808.
readResponseTextLimitedprovider HTTP helper with the same 8 KiB diagnostic budget used by related OAuth/provider integrations.Competition / linked PR analysis
No linked issue is being closed. I searched open PRs for the Google OAuth token response/body-read target and found no existing open PR covering this exact follow-up. The change is limited to
extensions/google/oauth.token.tsplus targeted regression tests inextensions/google/oauth.test.ts.Real behavior proof
6c1d7950f1b8e9eccdc1c2481509c2635d7805fd, calling productionexchangeCodeForTokensagainsthttps://oauth2.googleapis.com/tokenwith an invalid redacted client id and invalid code.Token exchange failed:diagnostic, and completed without requiring credentials or a successful account login.Review findings addressed
N/A — new follow-up PR, no review findings yet.
Regression Test Plan
extensions/google/oauth.test.tsresponse.text().requestTokenGrantwithout changing OAuth request construction, identity discovery, or project discovery behavior.Merge risk
Risk / Compatibility
Low risk. Successful token responses still use the existing JSON parsing path. Only non-OK diagnostic text is capped, so callers keep the same error prefix with a bounded body preview.
What was not changed
Root Cause
requestTokenGrant, read non-OK Google OAuth token responses withresponse.text(), which fully buffered external diagnostic bodies before the auth-provider failure was reported.readResponseTextLimited, bounding the body read at the source before the error is constructed, rather than trimming after an unbounded buffer already exists.extensions/google/oauth.token.tsis the owner for Gemini CLI OAuth token exchange and refresh grants; the change happens before downstream credential construction, identity discovery, and project discovery, so the diagnostic body is bounded at the provider boundary.