fix(cli): bound docs search API response reads#96251
Conversation
Replace raw response.json() with readResponseWithLimit to prevent unbounded buffering of the docs.openclaw.ai search API response, matching the defensive read pattern used across provider and ClawHub HTTP clients. Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 24, 2026, 12:31 AM ET / 04:31 UTC. Summary PR surface: Source +5. Total +5 across 1 file. Reproducibility: yes. from source inspection: current main still calls Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Use the shared bounded-read helper in the docs command, then land after contributor-provided real CLI proof and preferably a focused overflow regression test. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection: current main still calls Is this the best way to solve the issue? Yes, the implementation shape is the best narrow fix because it reuses the existing shared response-limit helper at the exact external response boundary. The remaining merge gap is proof and optionally command-level coverage, not a different architecture. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9e3a917d9ee0. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +5. Total +5 across 1 file. 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
|
|
Superseded by a new PR with committed tests and real CLI proof. |
Summary
Replace raw
response.json()withreadResponseWithLimitin theopenclaw docssearch command to prevent unbounded buffering of the docs.openclaw.ai search API response.The command already has a fetch timeout (30s via
AbortController), but the response body was unbounded. A large search response could force the CLI to buffer arbitrarily large payloads before parsing.Real behavior proof (required for external PRs)
Behavior addressed: Unbounded
response.json()call infetchDocsSearchreplaced with capped read viareadResponseWithLimit.Real environment tested: Linux, Node 24, OpenClaw main @ 0671c08
Exact steps or command run after fix:
node scripts/run-node.mjs --no-color docs "installation guide"Evidence after fix:
The CLI command completes without errors. The
readResponseWithLimitutility is already imported and tested inpackages/media-core/src/read-response-with-limit.test.ts.Observed result after fix: The docs search response is now read through
readResponseWithLimitwith an 8 MB cap. Normal queries work identically; an oversized response would error with "Docs search response exceeds N bytes" instead of buffering the entire body.What was not tested: An artificially oversized docs search response from docs.openclaw.ai was not tested (the API returns normal-sized results).
Tests and validation
readResponseWithLimithas dedicated unit test coverage atpackages/media-core/src/read-response-with-limit.test.ts.Risk
Low. The 8 MB cap is generous for a docs search API response.
readResponseWithLimitis the same utility used by provider JSON/binary reads and ClawHub HTTP clients.