{"record":{"id":"7d9fcdbfd1cc4e95","repo":"JuliusBrussee/caveman","slug":"cave-plan-fetch-failed-with-http-response-status","errorCode":null,"errorMessage":"cave plan fetch failed with HTTP ${response.status}","messagePattern":"cave plan fetch failed with HTTP (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":1960,"sourceCode":"}\n\nfunction cloneCanonical(value: unknown): unknown {\n  return JSON.parse(canonicalJSON(value)) as unknown;\n}\n\nfunction assemblyText(value: unknown): string {\n  return typeof value === \"string\" ? value : canonicalJSON(value);\n}\n\nasync function cavePlan(cave: Cave): Promise<CavePlan> {\n  // `/sdk/v1/cave-plan` is a gateway-owned project-key route. `controlURL` is\n  // reserved for control-api `/api/v1/*` surfaces and must never redirect this\n  // call to a route that service does not expose.\n  const response = await caveFetch(cave, `${cave.options.baseURL}/sdk/v1/cave-plan`, {\n    method: \"GET\",\n    headers: otlpHeaders(cave)\n  });\n  if (!response.ok) throw new Error(`cave plan fetch failed with HTTP ${response.status}`);\n  // Passed through verbatim: snake_case wire fields, every figure inferred/per-day.\n  return (await response.json()) as CavePlan;\n}\n\nfunction strictNonNegativeInt(value: unknown): number | null {\n  return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : null;\n}\n\nconst DEFAULT_HTTP_TIMEOUT_MS = 30_000;\n\n/**\n * Shared bounded transport for every SDK request.\n *\n * The explicit abort race is intentional: callers still settle on deadline when\n * a custom fetch implementation ignores AbortSignal. Native fetch also receives\n * the combined signal, so response-body reads and sockets are cancelled.\n */\nasync function caveFetch(cave: Cave, input: RequestInfo | URL, init: RequestInit = {}): Promise<Response> {","sourceCodeStart":1942,"sourceCodeEnd":1978,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/sdk/typescript/src/index.ts#L1942-L1978","documentation":"Error \"cave plan fetch failed with HTTP ${response.status}\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:1960 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The cave plan fetch returned a non-2xx status; check credentials and endpoint, 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-15T22:17:37.221Z"}