{"record":{"id":"c6049491838b9047","repo":"JuliusBrussee/caveman","slug":"oversized-response","errorCode":null,"errorMessage":"oversized_response","messagePattern":"oversized_response","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":879,"sourceCode":"      }\n      return response;\n    }\n  };\n}\n\n// ─── Runtime policy client ────────────────────────────────────────────────────\n\n/** Schema version this client accepts; anything else is rejected (fail closed). */\nconst RUNTIME_POLICY_SCHEMA_VERSION = \"caveman.runtime-policy.v1\";\n\n/** 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    }","sourceCodeStart":861,"sourceCodeEnd":897,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/sdk/typescript/src/index.ts#L861-L897","documentation":"Error \"oversized_response\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:879 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The response exceeded the size cap; narrow the request or paginate."],"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"}