Repository navigation
fix(googlechat): cancel unread auth response bodies before release - #115873
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 9:04 PM ET / August 1, 2026, 01:04 UTC. ClawSweeper reviewWhat this changesThe PR cancels an unread Google OAuth response body when the auth transport rejects an oversized response before reading it, and adds a loopback regression test. Merge readinessThis PR remains necessary: current Priority: P2 Review scores
Verification
How this fits togetherGoogle Chat authentication uses flowchart LR
A[Google auth library request] --> B[Google Chat auth transport]
B --> C[SSRF-guarded fetch]
C --> D[Response size guard]
D -->|accepted| E[Read and buffer body]
D -->|oversized| F[Cancel unread body]
E --> G[Release dispatcher]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +6, Tests +86. Total +92 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Merge the focused auth-transport lifecycle repair so every Google Chat guarded-response path either reads or starts cancelling a response body before dispatcher release. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: an oversized declared response makes Is this the best way to solve the issue? Yes. Cancelling only when AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 65717fd3be89. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
a404851 to
5017ead
Compare
|
Refreshed onto current The branch was 60 commits behind. Nothing upstream had touched either file ( No changes to the patch itself. |
The size guard in readGoogleAuthResponseBytes inspects content-length and throws before it reaches response.body.getReader(), so an oversized auth response leaves the stream untouched and the finally block releases the dispatcher without cancelling it. This is the same shape openclaw#111290 just fixed in api.ts, applied to the auth transport's own guard site.
5017ead to
9134cee
Compare
|
Landing verification for original contributor head
Owner-boundary fix is six production lines and matches the Google Chat API sibling and guarded redirect cleanup; no config, security policy, timeout, or public API changed. |
|
Merged via squash.
|
* commit '441d6ab254df14fb6939a8a261f474904ff9c500': (388 commits) fix(qqbot): ignore blank app id fallbacks (openclaw#109460) fix(feishu): consume implicit reply targets across media delivery (openclaw#117196) fix(exec): preserve approved command output when sessions resume (openclaw#117177) fix(qa): use public subagent fanout evidence (openclaw#116832) fix(googlechat): cancel unread auth response bodies before release (openclaw#115873) fix(queue): prevent cron saturation from starving hook dispatch (openclaw#116666) fix(gateway): sessions.steer retry no longer interrupts an active run when replaying a cached idempotency key (openclaw#116969) fix(irc): config validation rejects documented channels.irc.configWrites key (openclaw#112392) fix(mistral): keep terminal error branch lint-clean fix(onboard): stop a full reset from resetting the default workspace when the config is unreadable (openclaw#114110) refactor(i18n): remove unused Apple contradiction report (openclaw#117182) fix(google): stop scraping Gemini CLI OAuth credentials (openclaw#117167) perf: count large histories before Gateway prewarm (openclaw#117118) fix(signal): restore provider-safe original attachment filenames (openclaw#115107) refactor(channels): unify setup ownership across bundled channels (openclaw#117188) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) ...
…penclaw#115873) The size guard in readGoogleAuthResponseBytes inspects content-length and throws before it reaches response.body.getReader(), so an oversized auth response leaves the stream untouched and the finally block releases the dispatcher without cancelling it. This is the same shape openclaw#111290 just fixed in api.ts, applied to the auth transport's own guard site.
* commit 'ae4e662145b6aa162777cdb1c011b3f04ddd230d': (388 commits) fix(qqbot): ignore blank app id fallbacks (openclaw#109460) fix(feishu): consume implicit reply targets across media delivery (openclaw#117196) fix(exec): preserve approved command output when sessions resume (openclaw#117177) fix(qa): use public subagent fanout evidence (openclaw#116832) fix(googlechat): cancel unread auth response bodies before release (openclaw#115873) fix(queue): prevent cron saturation from starving hook dispatch (openclaw#116666) fix(gateway): sessions.steer retry no longer interrupts an active run when replaying a cached idempotency key (openclaw#116969) fix(irc): config validation rejects documented channels.irc.configWrites key (openclaw#112392) fix(mistral): keep terminal error branch lint-clean fix(onboard): stop a full reset from resetting the default workspace when the config is unreadable (openclaw#114110) refactor(i18n): remove unused Apple contradiction report (openclaw#117182) fix(google): stop scraping Gemini CLI OAuth credentials (openclaw#117167) perf: count large histories before Gateway prewarm (openclaw#117118) fix(signal): restore provider-safe original attachment filenames (openclaw#115107) refactor(channels): unify setup ownership across bundled channels (openclaw#117188) fix: allow gateway service commands for named profiles (openclaw#116314) fix(plugins): invalidate bundled artifact locations after metadata refresh (openclaw#117041) fix(ollama): honor model requests and pull completion contracts (openclaw#117171) fix(agents): prevent fallback after stale lifecycle abort (openclaw#117168) fix(telegram): confirm polling before long poll (openclaw#116970) ...
Follow-up to #111290, as offered in review there.
What Problem This Solves
Fixes an issue where a Google Chat operator whose auth endpoint returns an oversized response would leave a live HTTP response body unread and uncancelled when the SSRF dispatcher is released, holding the socket open until the runtime gets around to it.
Nothing errors and nothing is logged — the request fails with the expected size error, and the leak sits behind it.
Why This Change Was Made
#111290 established the invariant for this extension and documented it at the
api.tsguard site:release()does not cancel streams, so a status-only response has to be cancelled explicitly before release.The auth transport has its own guard site, and it was not covered by that change.
readGoogleAuthResponseBytesinspectscontent-lengthfirst:The throw happens before
getReader(), so on that path the stream is never touched and thefinallyreleases the dispatcher with the body still unread. This is the same shape as the one just fixed, reached by a different route: there the body is unread because the response is status-only, here because the guard rejected it early.The fix mirrors the merged one exactly — same predicate, same non-awaited cancellation, same reasoning about the tee'd-capture deadlock — so both guard sites in this extension now read alike.
Note this is only reachable through the size guard's own rejection path, so the fix is narrow by construction: a response that is read normally is untouched.
User Impact
An oversized auth response no longer leaves its body open when the dispatcher is released; the socket is torn down at the same point it already is on every other path. Normal auth responses are unaffected.
Evidence
Added
extensions/googlechat/src/google-auth.fetchok.transport.test.ts, following the harness #111290 landed: a real loopback server, the realfetchWithSsrFGuard, and the realrelease— the wrapper only records whatrelease()observes and then delegates, so the assertions run againstcloseDispatcher→waitForDispatcherCloserather than a stub.Both directions are covered, and the control case is the point: the site does not leak generally, only on the throw-before-read path.
release()observes, beforecontent-length: 1048577{ bodyIsNull: false, bodyUsed: false }{ bodyIsNull: false, bodyUsed: true }{ bodyIsNull: false, bodyUsed: true }Against the unfixed source the first case fails with exactly that difference:
The control case passes before and after, so the test is measuring the leak rather than the request path.
After the fix, the whole extension suite is green:
oxfmt --checkis clean on both touched files.AI-assisted: written and verified with an AI coding agent; the failing-test-first measurement, the control case, and the suite run above were reviewed by me.