Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 8:46 AM ET / 12:46 UTC. Summary PR surface: Source -5, Tests +31. Total +26 across 3 files. Reproducibility: yes. Source inspection gives a high-confidence current-main path: pass a no-reader Response-like object with a large Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land one canonical fail-closed bounded-reader fix, with the SDK-visible no-reader behavior either explicitly accepted by a maintainer or covered by focused public-helper tests before merge. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection gives a high-confidence current-main path: pass a no-reader Response-like object with a large Is this the best way to solve the issue? Mostly yes. The fail-closed helper shape is the narrow maintainable way to make the byte cap honest, but the SDK-exported edge behavior should be accepted or covered before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 60f0749b7fb3. Label changesLabel justifications:
Evidence reviewedPR surface: Source -5, Tests +31. Total +26 across 3 files. View PR surface stats
What 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
Review history (3 earlier review cycles)
|
|
Addressed clawsweeper P1 findings. Changes:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
Fixed check-lint CI: replaced @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper re-review The previous re-review request was acknowledged ~15 min ago. CI is all green (71 ✅, check-lint passed). PR body has been updated with L2 terminal proof including Content-Length guard demonstration. |
|
Addressed round 2 findings: no-reader fallback now fails closed — returns empty immediately instead of calling Changes in this round:
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…treaming fallback The non-streaming fallback in readResponseBodySnippet called response.text() without any size limit, buffering the entire response before the maxBytes check. Switch to readResponsePrefix which caps the read at maxBytes bytes. The streaming path was already bounded — only the !body.getReader fallback was vulnerable. Fixes openclaw#101269
…nt-Length guard - Add null-body early return in readResponsePrefix to avoid arrayBuffer() call - Add Content-Length check before arrayBuffer() in non-streaming path - Export readResponsePrefix from http-body.ts (was private) - Replace response.text() with readResponsePrefix in readResponseBodySnippet - Add 2 regression tests for Content-Length gate and null-body short-circuit Ref. openclaw#101270
… arrayBuffer Replace the Content-Length guard approach with a simpler fail-closed strategy: when the response has no ReadableStream reader, return empty immediately instead of falling back to arrayBuffer()/text(). The streaming path (which handles all production HTTP responses in Node.js undici fetch) is unchanged. - Remove arrayBuffer() fallback from readResponsePrefix no-reader branch - Rewrite body-less path tests to use streaming Response with Blob - Add regression test asserting no-reader path never calls arrayBuffer() Ref. openclaw#101270
f928ff3 to
7604a19
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing due to inactivity. |
Summary
Problem:
readResponseBodySnippet()non-streaming fallback (!body.getReader) callsresponse.text()without any size bound, buffering the entire response before themaxBytescheck runs.Solution: Replace
response.text()withreadResponsePrefix(response, maxBytes)which caps the read atmaxBytesbytes regardless of path. The non-streaming fallback inreadResponsePrefixitself is hardened with a fail-closed guard: when the response has noReadableStreamreader, it returns empty immediately — never callingarrayBuffer()ortext()which would materialize the full body.What changed:
readResponsePrefixexported fromhttp-body.ts(was private). Non-streaming fallback inhttp-error-body.tsuses it instead ofresponse.text(). The no-reader branch ofreadResponsePrefixnow fails closed (returns empty + truncated) instead of falling back to whole-bodyarrayBuffer(). Regression tests assert thatarrayBuffer()is never invoked for no-reader or null-body responses.What did NOT change: Streaming path behavior (already bounded). Return type/API surface of
readResponseBodySnippet. Any caller behavior — all callers pass the same limits.Fixes #101269
Root Cause
readResponseBodySnippet()atsrc/infra/http-error-body.ts:8-9callsresponse.text()when no streaming reader is available (!body.getReader). Unlike the streaming path which reads chunk-by-chunk up tomaxBytes,response.text()buffers the entire HTTP response body before any size check. The initial fix routed this throughreadResponsePrefix(), but that helper's own no-reader fallback calledresponse.arrayBuffer()— the same unbounded-read pattern.What Problem This Solves
readResponseBodySnippet()is called from Gateway error-handling paths to produce a diagnostic snippet of error response bodies. Whenresponse.bodyis aReadableStream(always true in Node.js undici fetch), the streaming path correctly bounds reads. But for synthetic Response objects or edge-case HTTP responses without a readable stream, the fallback path could materialize a multi-megabyte body before truncation. This fix ensures that responses without a streaming reader are handled without any whole-body allocation, matching the fail-closed pattern already used by adjacent web helpers.Real behavior proof
Behavior addressed: No-reader Response objects (synthetic or edge-case) now return empty without calling
arrayBuffer()ortext().Real environment tested: Linux x64 (kernel 4.19.112), Node.js v24.13.1, OpenClaw commit a78538d (PR base)
Exact steps or command run after this patch:
After-fix evidence:
Observed result after the fix: All 5 real-world test cases confirm fail-closed behavior — no-reader and null-body Response objects never trigger
arrayBuffer(). The streaming path correctly caps reads atmaxBytes. All 11 unit tests pass with 2 regression tests assertingarrayBuffer()is not called for no-reader or null-body responses.What was not tested: Full end-to-end Gateway error handling — only the
readResponseBodySnippet()function was verified via direct import call. The no-reader path is inherently a synthetic/edge-case scenario in Node.js undici fetch, where all HTTP responses provide aReadableStreambody.Changes
src/infra/http-body.ts:189readResponsePrefix(was private function)src/infra/http-body.ts:199-208arrayBuffer()src/infra/http-error-body.ts:1,10readResponsePrefix, replace unboundedresponse.text()with boundedreadResponsePrefixsrc/infra/http-error-body.test.tsResponse; add regression tests for fail-closed no-reader and null-body pathsRisk checklist
Linked context