fix(speech): bound TTS response reads#96874
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 25, 2026, 8:31 PM ET / 00:31 UTC. Summary PR surface: Source +18, Tests +81. Total +99 across 4 files. Reproducibility: yes. from source inspection: current main still calls unbounded response.text()/response.json() on the affected TTS success paths. The PR body adds after-fix loopback proof plus a negative unbounded-read control, but I did not execute commands in this read-only review. Review metrics: 1 noteworthy metric.
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
Security Review detailsBest possible solution: Land the bounded-read hardening after maintainers accept the 16 MiB fail-fast cap for these TTS providers and exact-head checks stay clean. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection: current main still calls unbounded response.text()/response.json() on the affected TTS success paths. The PR body adds after-fix loopback proof plus a negative unbounded-read control, but I did not execute commands in this read-only review. Is this the best way to solve the issue? Yes: the patch uses existing public plugin-sdk bounded-reader helpers, keeps provider behavior in owner modules, and matches sibling generated-media size caps. The remaining question is maintainer acceptance of the 16 MiB cap, not a better implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against dd0e4f6e61b8. Label changesLabel justifications:
Evidence reviewedPR surface: Source +18, Tests +81. Total +99 across 4 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
|
|
Merge-ready for 2774988. Local and ClawSweeper review clean, CI green, best narrow fix, and follows the established bounded TTS/media response-read pattern. Maintainer cap accepted: 16 MiB is defensible here because these are generated-audio TTS responses wrapped in JSON/base64, not arbitrary file downloads; the cap matches OpenClaw's existing generated-audio/media budget used by sibling TTS/media providers, and gives roughly 12 MiB decoded audio after base64 overhead, which is enough for normal OpenClaw TTS replies/voice notes. Long-form narration above that should use a deliberate product/config path, not unbounded provider reads. |
(cherry picked from commit 2f851ec)
What Problem This Solves
speech/TTS success-path 之前会对不可信响应体执行无界
await response.text()/await response.json(),音频生成 JSON/base64 或 Seed frame 随音频长度膨胀时可能导致 OOM/hang。Changes
response.text()改为共享readResponseWithLimit,16MiB cap,overflow 时 cancel stream。response.text()改为共享readResponseWithLimit,16MiB cap,overflow 时 cancel stream。response.json()改为共享readProviderJsonResponse,复用 provider JSON 16MiB cap。Real behavior proof
Behavior addressed:
.text()会完整 buffer 超过 cap 的 body。Real environment tested:
fix/bound-speech-tts,基于最新upstream/mainrebase 后执行。node:httploopback proxy + productionfetchWithSsrFGuard路径;目标 URL 使用http://example.com,代理把响应转成本机无 Content-Length 流式 body。Exact steps:
PNPM_CONFIG_MODULES_DIR=/media/vdc/0668001470/workSpace/claw-campaign/openclaw/node_modules node --import tsx scratchpad/proof-speech-tts-bound.ts 2>&1 | tee scratchpad/proof-speech-tts-bound.outPNPM_CONFIG_MODULES_DIR=/media/vdc/0668001470/workSpace/claw-campaign/openclaw/node_modules node scripts/run-vitest.mjs extensions/volcengine/tts.test.ts extensions/xiaomi/speech-provider.test.tsPNPM_CONFIG_MODULES_DIR=/media/vdc/0668001470/workSpace/claw-campaign/openclaw/node_modules node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfoPNPM_CONFIG_MODULES_DIR=/media/vdc/0668001470/workSpace/claw-campaign/openclaw/node_modules node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo.agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/mainObserved result:
[proof] 5 PASS, 0 FAIL/[proof] ALL PASSautoreview clean: no accepted/actionable findings reportedWhat was not tested:
Evidence
Label: security
AI-assisted.