{"record":{"id":"835010ff5d253d1a","repo":"diegosouzapw/OmniRoute","slug":"remote-image-exceeds-maxbytes-byte-limit","errorCode":null,"errorMessage":"Remote image exceeds ${maxBytes} byte limit","messagePattern":"Remote image exceeds (.+?) byte limit","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/shared/network/remoteImageFetch.ts","lineNumber":147,"sourceCode":"        ...(init as Parameters<typeof undiciFetch>[1]),\n        dispatcher,\n      })) as unknown as Response;\n    } finally {\n      await dispatcher.close();\n    }\n  }) as typeof fetch;\n}\nfunction combineSignals(signal: AbortSignal | undefined, timeoutMs: number) {\n  const timeoutSignal = AbortSignal.timeout(timeoutMs);\n  if (!signal) return timeoutSignal;\n  return AbortSignal.any([signal, timeoutSignal]);\n}\n\nasync function readResponseBuffer(response: Response, maxBytes: number) {\n  const contentLengthHeader = response.headers.get(\"content-length\");\n  const contentLength = contentLengthHeader ? Number.parseInt(contentLengthHeader, 10) : null;\n  if (contentLength !== null && Number.isFinite(contentLength) && contentLength > maxBytes) {\n    throw new Error(`Remote image exceeds ${maxBytes} byte limit`);\n  }\n\n  if (!response.body) {\n    const buffer = Buffer.from(await response.arrayBuffer());\n    if (buffer.byteLength > maxBytes) {\n      throw new Error(`Remote image exceeds ${maxBytes} byte limit`);\n    }\n    return buffer;\n  }\n\n  const reader = response.body.getReader();\n  const chunks: Buffer[] = [];\n  let totalBytes = 0;\n\n  try {\n    while (true) {\n      const { done, value } = await reader.read();\n      if (done) break;","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/shared/network/remoteImageFetch.ts#L129-L165","documentation":"Size-limit error from readResponseBuffer(): the remote media response exceeds maxBytes — either declared via Content-Length up front or accumulated while streaming the body. It enforces a download bound so remote images/media cannot exhaust server memory.","triggerScenarios":"Thrown at src/shared/network/remoteImageFetch.ts:147 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase maxBytes in the fetch options if larger media is legitimate","Serve a smaller/compressed image or use a resized variant of the asset","Reject up front using Content-Length before downloading the body","Have the client supply a smaller asset URL for the vision/media call"],"exampleFix":null,"handlingStrategy":"validation","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"}