{"record":{"id":"7c01b7e4f5a5166f","repo":"JuliusBrussee/caveman","slug":"cave-request-failed-response-status","errorCode":null,"errorMessage":"cave request failed (${response.status})","messagePattern":"cave request failed \\((.+?)\\)","errorType":"exception","errorClass":"CaveRequestError","httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":2057,"sourceCode":"  if (!response.ok) throw new Error(await response.text());\n  return response.json();\n}\n\nexport class CaveRequestError extends Error {\n  constructor(readonly status: number, readonly path: string, message: string) {\n    super(message);\n    this.name = \"CaveRequestError\";\n  }\n}\n\nasync function request(cave: Cave, path: string, body?: unknown, workflow?: string, trace?: TraceContext, extraHeaders?: Record<string, string>): Promise<Record<string, unknown>> {\n  const init: RequestInit = {\n    method: body === undefined ? \"GET\" : \"POST\",\n    headers: { ...headers(cave, workflow ?? cave.options.defaultWorkflow ?? \"unlabeled-workflow\", undefined, undefined, trace), ...extraHeaders }\n  };\n  if (body !== undefined) init.body = JSON.stringify(body);\n  const response = await caveFetch(cave, `${cave.options.baseURL}${path}`, init);\n  if (!response.ok) throw new CaveRequestError(response.status, path, `cave request failed (${response.status})`);\n  let decoded: unknown;\n  try {\n    if (typeof response.text === \"function\") {\n      decoded = JSON.parse(await response.text());\n    } else if (typeof response.json === \"function\") {\n      decoded = await response.json();\n    } else {\n      throw new Error(\"missing response decoder\");\n    }\n  } catch {\n    throw new CaveRequestError(response.status, path, \"cave response was not valid JSON\");\n  }\n  if (decoded === null || typeof decoded !== \"object\" || Array.isArray(decoded)) {\n    throw new CaveRequestError(response.status, path, \"cave response must be a JSON object\");\n  }\n  return decoded as Record<string, unknown>;\n}\n","sourceCodeStart":2039,"sourceCodeEnd":2075,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/sdk/typescript/src/index.ts#L2039-L2075","documentation":"Error \"cave request failed (${response.status})\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:2057 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The cave request failed; inspect the HTTP status, fix the request or credentials, and 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"}