fix(openrouter): bound video catalog JSON reads#96505
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 1:00 PM ET / 17:00 UTC. Summary PR surface: Source +4, Tests +55. Total +59 across 2 files. Reproducibility: yes. Source inspection shows current main and Review metrics: 2 noteworthy metrics.
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:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land one bounded-reader fix for this call site, preserve direct overflow coverage, accept the shared 16 MiB cap, and then close or supersede the alternate branch. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main and Is this the best way to solve the issue? Yes. Reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4ae0a5d958a0. Label changesLabel justifications:
Evidence reviewedPR surface: Source +4, Tests +55. Total +59 across 2 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
|
|
hi @sallyom there is a bounded response pr ready to merge, I'd really appreciate it if you could take a look! |
|
Merge-ready from maintainer review. This is the best narrow fix for the OpenRouter video catalog success-body read: it changes the exact Autoreview is clean with no accepted/actionable findings. The targeted OpenRouter provider test passes locally, and current CI is green. I do not see a breaking-change or compatibility concern for supported OpenRouter video catalog behavior; the only changed behavior is the intended fail-fast cap for oversized/runaway catalog success bodies using the existing shared provider JSON limit. |
Summary
Responsebodies, including an oversized stream that must be canceled.What Problem This Solves
extensions/openrouter/video-model-catalog.tsfetched/videos/modelsand parsed successful responses withresponse.json(). That bypassed the provider response byte cap, so a provider endpoint or user-configured OpenRouter-compatiblebaseUrlcould stream an oversized JSON success body and make the runtime buffer it before parsing.User Impact
readProviderJsonResponse, which wrapsreadResponseWithLimitwith the shared 16 MiB cap and overflow cancellation. This extension now uses that SDK contract instead of a one-off parser.Origin / follow-up
Follow-up to #95420. That PR bounded a sibling OpenRouter catalog response path; this patch applies the same shared provider JSON reader to the OpenRouter video model catalog path.
Competition / linked PR analysis
Related open PR scan: checked for an open PR covering an OpenRouter video model catalog bounded response reader and did not find one. This patch is intentionally limited to
extensions/openrouter/video-model-catalog.tsand its existing provider test so it does not overlap with open bounded-reader work in other extensions.Real behavior proof
readProviderJsonResponse, which enforces the shared 16 MiB cap and cancels the stream on overflow.ResponseandReadableStreambodies. No OpenRouter credential was used; the proof targets the response-body boundary after the HTTP result is returned.{ "proof": "openrouter-video-catalog-bounded-json-reader", "boundary": "real Response and ReadableStream body without Content-Length", "reader": "src/agents/provider-http-errors.ts readProviderJsonResponse", "caller": "extensions/openrouter/video-model-catalog.ts OpenRouter video model catalog success path", "normalPathModel": "openrouter/video-ok", "overflowMessage": "OpenRouter video models request failed: JSON response exceeds 16777216 bytes", "expectedMessage": "OpenRouter video models request failed: JSON response exceeds 16777216 bytes", "streamCanceled": true }ReadableStreamthat exceeds 16 MiB throwsOpenRouter video models request failed: JSON response exceeds 16777216 bytes; the stream cancellation hook ran, and the guarded fetch release callback was called./videos/modelsrequest was not run because the current environment does not provide an OpenRouter API key. Other OpenRouter response paths, including audio transcription, were not changed in this patch.Review findings addressed
No maintainer review findings are attached to this follow-up yet. The patch addresses the bounded-reader gap found while comparing the already-merged OpenRouter catalog fix with remaining OpenRouter video catalog response reads.
Regression Test Plan
extensions/openrouter/video-generation-provider.test.tsResponse; normal JSON still maps into catalog entries, and an oversized no-Content-Length stream fails at the shared 16 MiB cap.listOpenRouterVideoModelCatalogpath rather than only testing the helper, and asserts the overflow stream is canceled and the guarded fetch release callback runs. This directly guards the changed parser call site without adding a broader provider fixture.Merge risk
Risk / Compatibility
Low risk. Valid JSON responses under the shared provider cap follow the same parsing and catalog projection path as before. Responses over the cap now fail earlier with the same provider-reader error shape used by other provider JSON responses.
What was not changed
Maintainer-ready confidence
readProviderJsonResponsefromopenclaw/plugin-sdk/provider-http, keeping extension code on the existing SDK boundary.Root Cause
response.json()parser directly at the external response boundary, bypassing the shared provider JSON reader contract that is responsible for bounded response parsing.assertOkOrThrowHttpError. Replacing that call withreadProviderJsonResponsemoves the byte cap and cancellation behavior before JSON parsing can buffer an oversized body, while leaving endpoint selection, auth, caching, and catalog projection unchanged.