{"record":{"id":"8f4c30bf373545e8","repo":"JuliusBrussee/caveman","slug":"cave-provider-raw-path-not-allowed","errorCode":"cave_provider_raw_path_not_allowed","errorMessage":"cave_provider_raw_path_not_allowed","messagePattern":"cave_provider_raw_path_not_allowed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/sdk/typescript/src/index.ts","lineNumber":2086,"sourceCode":"}\n\nfunction providerClient(cave: Cave, provider: string, prefix: string, upstreamKey?: string) {\n  return {\n    provider,\n    responses: { create: (body: unknown, init?: { cave?: { latencyClass?: string; toolSessionId?: string } }) => providerFetch(cave, `${prefix}/responses`, body, cave.options.defaultWorkflow ?? \"unlabeled-workflow\", init?.cave, upstreamKey) },\n    chat: { completions: { create: (body: unknown, init?: { cave?: { toolSessionId?: string } }) => providerFetch(cave, `${prefix}/chat/completions`, body, cave.options.defaultWorkflow ?? \"unlabeled-workflow\", init?.cave, upstreamKey) } },\n    raw: (input: RequestInfo | URL, init?: RequestInit) => providerRawFetch(cave, prefix, input, init, upstreamKey)\n  };\n}\n\nfunction providerRawFetch(cave: Cave, prefix: string, input: RequestInfo | URL, init?: RequestInit, upstreamKey?: string): Promise<Response> {\n  const base = new URL(cave.options.baseURL);\n  const request = input instanceof Request\n    ? new Request(input, init)\n    : new Request(new URL(String(input), base), init);\n  const target = new URL(request.url);\n  if (target.origin !== base.origin || (target.pathname !== prefix && !target.pathname.startsWith(`${prefix}/`))) {\n    throw new Error(\"cave_provider_raw_path_not_allowed\");\n  }\n  const merged = new Headers(request.headers);\n  const gatewayHeaders = headers(cave, cave.options.defaultWorkflow ?? \"unlabeled-workflow\", upstreamKey);\n  for (const [name, value] of Object.entries(gatewayHeaders)) {\n    if (name !== \"content-type\") merged.set(name, value);\n  }\n  return caveFetch(cave, new Request(request, { headers: merged }));\n}\n\nasync function providerFetch(cave: Cave, path: string, body: unknown, workflow: string, hint?: Record<string, unknown>, upstreamKey?: string, trace?: TraceContext) {\n  const assemblyHeader = body !== null && typeof body === \"object\" ? assemblyRequestHeaders.get(body as object) : undefined;\n  const response = await caveFetch(cave, `${cave.options.baseURL}${path}`, {\n    method: \"POST\",\n    headers: headers(cave, workflow, upstreamKey, assemblyHeader ? { ...hint, assemblyHeader } : hint, trace),\n    body: JSON.stringify(body)\n  });\n  if (!response.ok) throw new Error(await response.text());\n  return response.json();","sourceCodeStart":2068,"sourceCodeEnd":2104,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/sdk/typescript/src/index.ts#L2068-L2104","documentation":"Security guard in the SDK raw provider-request path: the Request URL does not match the configured provider prefix (same origin, pathname equal to or under the prefix). Raw passthrough is only permitted to the mounted provider route, so anything else is refused before the request leaves the SDK.","triggerScenarios":"Thrown at packages/sdk/typescript/src/index.ts:2086 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Point the Request at the same path you would pass to providerClient (e.g. <prefix>/responses or <prefix>/chat/completions)","Use the structured responses/chat client instead of raw Request passthrough","Fix the baseURL or prefix configuration so origins match"],"exampleFix":null,"handlingStrategy":"validation","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"}