Skip to content

fix(pixverse): bound video-generation success JSON response reads at 16 MiB#96885

Closed
wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/pixverse-video-bounded-read
Closed

fix(pixverse): bound video-generation success JSON response reads at 16 MiB#96885
wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/pixverse-video-bounded-read

Conversation

@wangmiao0668000666

Copy link
Copy Markdown
Contributor

What Problem This Solves

extensions/pixverse/video-generation-provider.ts:189 calls await response.json() with no byte-level cap. A hostile, compromised, or misconfigured PixVerse endpoint can return a success status with no Content-Length and stream an arbitrarily large JSON payload, causing OOM.

The fix routes through readProviderJsonResponse (openclaw/plugin-sdk/provider-http, 16 MiB default cap), which reads the body as a bounded stream and cancels on overflow. The existing readPixVerseSuccess layer is preserved for PixVerse-specific envelope validation.

Changes

  • extensions/pixverse/video-generation-provider.ts:186-190 — replace payload = await response.json() in readPixVerseJson with readProviderJsonResponse(response, label). Removes the manual try/catch (malformed JSON handling is built into the SDK helper). Type changed from Pick<Response, "json"> to Response.
  • extensions/pixverse/video-generation-provider.test.ts — add readProviderJsonResponseMock to destructured mock imports (shared mock handles the delegation).
  • src/plugin-sdk/test-helpers/provider-http-mocks.ts — add readProviderJsonResponseMock to shared mock interface and the vi.mock("openclaw/plugin-sdk/provider-http") block, so extension tests can mock it alongside other provider-http exports.

Real behavior proof

Drives readProviderJsonResponse over a real node:http server (chunked transfer, no Content-Length). Node v22.22.0.

=== PixVerse bounded-read proof ===

  PASS  happy path: status ok
  PASS  happy path: returns object with Resp — video_id=123
  PASS  oversized: throws bounded error with label — err=PixVerse test: JSON response exceeds 16777216 bytes
  PASS  oversized: bytes on wire stayed near cap (< 20 MiB) — bytesSent=18.4 MiB, cap=16 MiB

=== PixVerse bounded-read: 4/4 passed ===
  • Behavior addressed: unbounded response.json() on PixVerse video generation success responses; now capped at 16 MiB (SDK default) with cancellation on overflow.
  • Real environment tested: real node:http server (127.0.0.1, chunked transfer, no Content-Length). Node v22.22.0.
  • Exact steps: node --import tsx _proof_pixverse.mts (working tree only, not committed)
  • Evidence after fix: 4/4 assertions pass. Happy path: valid PixVerse envelope parsed correctly. Oversized (endless chunked stream): throws "JSON response exceeds 16777216 bytes" at ~18.4 MiB.
  • What was not tested: live PixVerse API call (the proof exercises the same readProviderJsonResponse helper used in production).

Out of scope

  • Other unbounded response.json() call sites in extensions/pixverse/ — covered in separate bounded-read sibling PRs.
  • Default cap policy — 16 MiB is the SDK helper default, matching all other non-image provider JSON reads.

Risk

  • Low: swap from response.json() to readProviderJsonResponse. Error behavior preserves the same upstream catch path. Byte cap is 16 MiB — invisible to normal PixVerse JSON responses (typically < 1 MiB).
  • Tested: 15/15 existing unit tests pass.

Diff stats

3 files changed, 10 insertions(+), 7 deletions(-)

AI-assisted: implemented and proof-tested with AI assistance; reviewed by a human before submission.

…16 MiB

Replace unbounded response.json() in readPixVerseJson with
readProviderJsonResponse from openclaw/plugin-sdk/provider-http.
This prevents OOM from hostile or misconfigured PixVerse endpoints.

Also adds readProviderJsonResponseMock to the shared provider-http
test-mocks so extension tests can mock it alongside other provider-http
exports.

Co-Authored-By: Claude <[email protected]>
@clawsweeper

clawsweeper Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 25, 2026, 10:33 PM ET / 02:33 UTC.

Summary
The PR changes PixVerse video-generation success response parsing to use the shared bounded provider JSON reader and updates the provider-http test mock cleanup.

PR surface: Source +3. Total +3 across 2 files.

Reproducibility: yes. Current main directly calls response.json() in readPixVerseJson; an oversized chunked PixVerse upload/create success body can exercise that path, and the PR body shows the after-fix bounded reader behavior on a real local HTTP server.

Review metrics: 1 noteworthy metric.

  • Success JSON Cap: 1 PixVerse success parser changed to 16 MiB bounded reads. This is the compatibility-sensitive behavior maintainers need to accept before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Let current-head CI finish and confirm no PixVerse or plugin-SDK failures before merge.

Risk before merge

  • [P1] Existing custom or misbehaving PixVerse endpoints that return success JSON over 16 MiB will now fail with a bounded error instead of being fully buffered; maintainers should explicitly accept that fail-closed compatibility change.

Maintainer options:

  1. Accept The Shared Cap (recommended)
    Land after checks if maintainers agree PixVerse success JSON over 16 MiB should fail closed like other provider JSON reads.
  2. Hold For Provider Evidence
    Pause and ask for PixVerse API evidence if maintainers suspect normal success envelopes can exceed 16 MiB.

Next step before merge

  • [P2] No repair job is needed; the branch already addresses the earlier mechanical blockers, leaving maintainer acceptance of the compatibility-sensitive cap and ordinary current-head validation.

Security
Cleared: The diff narrows provider response memory exposure and does not add dependencies, workflow changes, package-resolution changes, generated code, or new secrets handling.

Review details

Best possible solution:

Merge the shared bounded-reader change after maintainers accept the 16 MiB fail-closed cap for PixVerse success JSON and current-head checks complete.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main directly calls response.json() in readPixVerseJson; an oversized chunked PixVerse upload/create success body can exercise that path, and the PR body shows the after-fix bounded reader behavior on a real local HTTP server.

Is this the best way to solve the issue?

Yes. Reusing readProviderJsonResponse is the narrow owner-boundary fix because the shared SDK helper already enforces the 16 MiB cap, malformed-JSON wrapping, and stream cancellation; duplicating PixVerse-local limit code would add drift.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6830aa39eaa1.

Label changes

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes sufficient after-fix terminal proof from a real local HTTP server showing bounded overflow and valid PixVerse envelope parsing.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is normal-priority defensive hardening for one plugin provider path with limited blast radius and no active outage evidence.
  • merge-risk: 🚨 compatibility: The PR intentionally changes oversized PixVerse success JSON from unbounded parsing to a hard 16 MiB failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes sufficient after-fix terminal proof from a real local HTTP server showing bounded overflow and valid PixVerse envelope parsing.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes sufficient after-fix terminal proof from a real local HTTP server showing bounded overflow and valid PixVerse envelope parsing.
Evidence reviewed

PR surface:

Source +3. Total +3 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 10 7 +3
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 10 7 +3

Acceptance criteria:

  • [P1] node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/pixverse/video-generation-provider.ts src/plugin-sdk/test-helpers/provider-http-mocks.ts.
  • [P1] node scripts/run-vitest.mjs extensions/pixverse/video-generation-provider.test.ts.

What I checked:

Likely related people:

  • vincentkoc: PR metadata and git history show commit 5366209 added/published the PixVerse provider files that contain the current success JSON parser. (role: introduced PixVerse provider; confidence: high; commits: 53662094c3db; files: extensions/pixverse/video-generation-provider.ts, extensions/pixverse/video-generation-provider.test.ts)
  • obviyus: Commit metadata for ace22fe shows this current-main snapshot of the PixVerse provider, shared provider HTTP errors, response limit helper, and provider HTTP mocks was committed by obviyus. (role: recent area committer; confidence: medium; commits: ace22feb3fe2; files: extensions/pixverse/video-generation-provider.ts, src/agents/provider-http-errors.ts, packages/media-core/src/read-response-with-limit.ts)
  • Alix-007: Merged PR fix(byteplus): bound video-generation success response reads #96606 applied the same shared bounded JSON reader pattern to BytePlus video-generation success responses. (role: adjacent bounded-read contributor; confidence: high; commits: 7b5ee739eb22; files: extensions/byteplus/video-generation-provider.ts, extensions/byteplus/video-generation-provider.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 26, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 26, 2026
@wangmiao0668000666
wangmiao0668000666 deleted the fix/pixverse-video-bounded-read branch June 26, 2026 05:44
wangmiao0668000666 added a commit to wangmiao0668000666/openclaw that referenced this pull request Jun 26, 2026
Remove the inner try/catch that wrapped readProviderJsonResponse errors
as 'malformed JSON response'. readProviderJsonResponse already handles
both overflow and malformed JSON internally. This matches the sibling
pixverse fix (openclaw#96885) which removed the same catch wrapper.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: pixverse proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant