fix(image-generation): bound OpenAI-compatible image API response reads#96261
fix(image-generation): bound OpenAI-compatible image API response reads#96261cxbAsDev wants to merge 2 commits into
Conversation
Replace raw response.json() with readResponseWithLimit to prevent unbounded buffering of image generation/edit API responses. Co-Authored-By: Claude <[email protected]>
|
Thanks for the context here. I did a careful shell check against current Current main already contains a stronger implementation from the merged canonical image-generation bounded-read PR, so this conflicting narrower branch is no longer a useful landing candidate. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the current main implementation from #96495 and close this narrower branch rather than merging duplicate bounded-read changes. Do we have a high-confidence way to reproduce the issue? Yes, at source and history level. Is this the best way to solve the issue? No for this branch as a landing path. The current main implementation is the better fix because it uses the shared bounded reader with image-sized caps and broader sibling-provider coverage. Security review: Security review cleared: The diff narrows provider-response buffering exposure and does not add dependencies, workflows, lockfiles, permissions, secrets handling, package metadata, or downloaded-code execution paths. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against cee2aca40912; fix evidence: commit 527f8f0cbba1, main fix timestamp 2026-06-26T11:08:30Z. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
…fixes Replace custom readResponseWithLimit + JSON.parse with the shared readProviderJsonResponse from provider-http-errors, and add arrayBuffer to all image gen test mock response objects so the bounded read path works in tests. Co-Authored-By: Claude <[email protected]>
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Replace custom
readResponseWithLimit+JSON.parsewith the sharedreadProviderJsonResponsefromprovider-http-errors.tsin the OpenAI-compatible image generation provider. Update test mock response objects witharrayBufferso the bounded read path works in tests.Real behavior proof (required for external PRs)
Behavior addressed: Custom bounded read replaced with shared
readProviderJsonResponse. Test mocks updated witharrayBuffersupport.Real environment tested: Linux, Node 24, OpenClaw main @ 56d95b1
Exact steps or command run after fix:
Evidence after fix:
All 5 tests pass including:
generates images via JSON request body— normal JSON pathgenerates images via multipart request body— multipart pathhonors default operation timeouts and empty-response errors— edge casewraps malformed successful image responses with provider-owned errors— error wrapping preservedMock responses now include
arrayBufferalongsidejsonsoreadProviderJsonResponsecan read the body throughreadResponseWithLimit.Observed result after fix: Image API response reads use the shared
readProviderJsonResponsewith the standard 16 MB cap. Error wrapping is preserved through the provider-owned failure label.What was not tested: A live image generation API call against a real endpoint was not tested.
Tests and validation
openai-compatible-image-provider.test.ts: 5/5 passed ✅Risk
Low. Uses shared
readProviderJsonResponsewhich is the standard bounded reader for all provider JSON responses. No custom bounded-read implementation remains.