{"record":{"id":"7ac0003f431e0218","repo":"JuliusBrussee/caveman","slug":"runtime-policy-response-stream-returned-invalid-by","errorCode":null,"errorMessage":"runtime policy response stream returned invalid bytes","messagePattern":"runtime policy response stream returned invalid bytes","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":890,"sourceCode":"/** Runtime-policy envelopes are KB-sized; stop a hostile body after 1 MiB. */\nconst RUNTIME_POLICY_MAX_RESPONSE_BYTES = 1024 * 1024;\n\nasync function readRuntimePolicyResponseText(response: Response): Promise<string> {\n  const contentLength = response.headers?.get?.(\"content-length\");\n  if (typeof contentLength === \"string\" && /^[0-9]+$/.test(contentLength) && Number(contentLength) > RUNTIME_POLICY_MAX_RESPONSE_BYTES) {\n    await Promise.resolve(response.body?.cancel?.()).catch(() => undefined);\n    throw new Error(\"oversized_response\");\n  }\n\n  const reader = response.body?.getReader?.();\n  if (!reader) throw new Error(\"bounded_response_unavailable\");\n  const chunks: Uint8Array[] = [];\n  let total = 0;\n  try {\n    while (true) {\n      const { done, value } = await reader.read();\n      if (done) break;\n      if (!(value instanceof Uint8Array)) throw new Error(\"runtime policy response stream returned invalid bytes\");\n      total += value.byteLength;\n      if (total > RUNTIME_POLICY_MAX_RESPONSE_BYTES) {\n        await Promise.resolve(reader.cancel()).catch(() => undefined);\n        throw new Error(\"oversized_response\");\n      }\n      chunks.push(value);\n    }\n  } finally {\n    try {\n      reader.releaseLock();\n    } catch {\n      // A broken fetch implementation must not mask the bounded-read result.\n    }\n  }\n  const joined = new Uint8Array(total);\n  let offset = 0;\n  for (const chunk of chunks) {\n    joined.set(chunk, offset);","sourceCodeStart":872,"sourceCodeEnd":908,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/sdk/typescript/src/index.ts#L872-L908","documentation":"Error \"runtime policy response stream returned invalid bytes\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:890 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The runtime policy stream returned invalid bytes; verify the endpoint and proxy, then retry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}