{"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":null,"httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":1974,"sourceCode":"function 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) {\n    discardResponse(response);\n    throw new Error(`cave plan fetch failed with HTTP ${response.status}`);\n  }\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 */","sourceCodeStart":1956,"sourceCodeEnd":1992,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/sdk/typescript/src/index.ts#L1956-L1992","documentation":"HTTP error from cavePlan in the SDK: the GET to the gateway's /sdk/v1/cave-plan route returned a non-success status. The plan that drives assembly could not be fetched; the status code is embedded in the message.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:1974 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry with backoff: transient 5xx/gateway restarts usually clear","Verify the project key and baseURL are correct and the gateway is reachable","Check gateway logs if the status persists (e.g. 401/403 auth, 404 route not deployed)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}