Repository navigation
Conversation
…esponseText Replace unbounded `response.text()` with `readResponseWithLimit()` which caps the read at `maxBytes` bytes. The non-streaming fallback is only reachable for synthetic or edge-case Response objects; all production HTTP responses already use the bounded streaming path. Same fail-closed pattern as the fix in readResponseBodySnippet (PR openclaw#101270).
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: this branch is a narrower partial fix for the hosted catalog streamless-read availability bug, while the related open PR rejects streamless hosted feed responses before the shared helper can allocate the whole body. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Keep the remaining fix on #101000, which fails closed before any streamless whole-body fallback, instead of maintaining two competing PR branches for the same hosted catalog availability bug. So I’m closing this here and keeping the remaining discussion on #101000. Review detailsBest possible solution: Keep the remaining fix on #101000, which fails closed before any streamless whole-body fallback, instead of maintaining two competing PR branches for the same hosted catalog availability bug. Do we have a high-confidence way to reproduce the issue? Yes. Current main has a source-visible streamless hosted catalog path that reads the full body before enforcing maxBytes, and this branch still reaches the shared helper fallback that calls response.arrayBuffer() for non-streaming bodies. Is this the best way to solve the issue? No. Replacing response.text() with readResponseWithLimit is only a partial mitigation here; the better fix is the related fail-closed hosted catalog path that rejects streamless untrusted feed responses before any whole-body fallback. Security review: Security review needs attention: The diff touches an untrusted hosted catalog response path and still leaves the whole-body streamless allocation path reachable through the shared helper.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against d8ffb1f30746. |
Add three test cases for readHostedCatalogResponseText bounded read: - within maxBytes returns hosted feed - exceeding maxBytes falls back to bundled catalog - readResponseWithLimit enforces byte limit before decoding Ref. openclaw#101405
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Summary
Problem:
readHostedCatalogResponseText()non-streaming fallback (!hasStreamingResponseBody) callsresponse.text()without any size bound, buffering the entire response before themaxBytescheck runs.Solution: Replace
response.text()+ post-hoc size check withreadResponseWithLimit()which caps the read atmaxBytesbytes regardless of path.What changed: Non-streaming fallback in
src/plugins/official-external-plugin-catalog.tsnow usesreadResponseWithLimit(already exported fromhttp-body.ts) instead ofresponse.text(). Three new tests verify the bounded read behavior.What did NOT change: Streaming path behavior (already bounded). Function signature/return type. Any caller behavior — all callers pass the same limits and receive the same throw-on-overflow semantics.
What Problem This Solves
readHostedCatalogResponseText()is called when loading the hosted official external plugin catalog feed. Whenresponse.bodyis aReadableStream(always true in Node.js undici fetch), the streaming path correctly bounds reads with per-chunk limits. 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 is the same unbounded-read pattern already fixed in
readResponseBodySnippet(PR #101270).Root Cause
readHostedCatalogResponseText()atsrc/plugins/official-external-plugin-catalog.ts:562callsresponse.text()when no streaming reader is available (!hasStreamingResponseBody). Unlike the streaming path which checkstotalBytes > maxBytesper chunk,response.text()buffers the entire HTTP response body before any size check.Real behavior proof
Behavior addressed: Non-streaming fallback now reads up to
maxBytesand throws on overflow, instead of materializing the entire body first.Real environment tested: Linux x64 (kernel 4.19.112), Node.js v24.13.1, OpenClaw commit 09977a9
Exact steps or command run after this patch:
Observed result after the fix:
readResponseWithLimitcorrectly bounds reads atmaxBytesand throws on overflow without first materializing the full body.After-fix evidence:
Test Files 1 passed (1), Tests 56 passed (56)
What was not tested: Full end-to-end hosted catalog download through a running Gateway — only the
readHostedCatalogResponseText()function vialoadHostedOfficialExternalPluginCatalogEntries(streaming/production path) andreadResponseWithLimit(bounded read contract). The non-streaming fallback is inherently a synthetic/edge-case scenario in Node.js undici fetch, where all HTTP responses provide aReadableStreambody.Changes
src/plugins/official-external-plugin-catalog.ts:10readResponseWithLimitfromhttp-body.jssrc/plugins/official-external-plugin-catalog.ts:561-566response.text()+ post-hoc TextEncoder check with boundedreadResponseWithLimitsrc/plugins/official-external-plugin-catalog.test.tsRisk checklist
readResponseWithLimitis already used by other code paths in production; 56 tests pass with 3 new dedicated test cases