{"record":{"id":"e5be9d760dfe6936","repo":"diegosouzapw/OmniRoute","slug":"video-extraction-broker-response-exceeded-its-byte","errorCode":null,"errorMessage":"Video extraction broker response exceeded its byte limit","messagePattern":"Video extraction broker response exceeded its byte limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/guardrails/videoBridgeBrokerClient.ts","lineNumber":52,"sourceCode":"export interface BrokerExtractionOptions {\n  frameCount: number;\n  focusWindow?: VideoFocusBounds | null;\n  samplingPolicy?: VideoSamplingPolicy;\n  signal?: AbortSignal;\n  timeoutMs: number;\n}\n\nconst MAX_BROKER_RESPONSE_BYTES = 32 * 1024 * 1024;\n\nexport function resolveVideoBridgeBrokerBaseUrl(_candidate?: string): string {\n  return resolveModelSyncInternalBaseUrl();\n}\n\nasync function readBoundedResponse(response: Response, maxBytes: number): Promise<unknown> {\n  const length = Number(response.headers.get(\"content-length\"));\n  if (Number.isFinite(length) && length > maxBytes) {\n    await response.body?.cancel(\"Video extraction broker response exceeded its byte limit\");\n    throw new Error(\"Video extraction broker response exceeded its byte limit\");\n  }\n  if (!response.body) {\n    throw new Error(\"Video extraction broker returned an invalid response\");\n  }\n  const reader = response.body.getReader();\n  const chunks: Uint8Array[] = [];\n  let totalBytes = 0;\n  try {\n    while (true) {\n      const { done, value } = await reader.read();\n      if (done) break;\n      totalBytes += value.byteLength;\n      if (totalBytes > maxBytes) {\n        await reader.cancel(\"Video extraction broker response exceeded its byte limit\");\n        throw new Error(\"Video extraction broker response exceeded its byte limit\");\n      }\n      chunks.push(value);\n    }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/guardrails/videoBridgeBrokerClient.ts#L34-L70","documentation":"readBoundedResponse enforces MAX_BROKER_RESPONSE_BYTES (32 MiB); the broker's extraction response exceeded that limit (detected via Content-Length or accumulated bytes), so the body is cancelled and the read aborted to protect memory.","triggerScenarios":"Thrown at src/lib/guardrails/videoBridgeBrokerClient.ts:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce frame count or lower frame resolution/quality to shrink the broker payload","Raise MAX_BROKER_RESPONSE_BYTES only if legitimate workloads need larger extractions","Check for runaway sampling policies producing excessive frames"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}