{"record":{"id":"4f125d64953a830d","repo":"JuliusBrussee/caveman","slug":"recordoutcome-control-api-responded-status","errorCode":null,"errorMessage":"recordOutcome: control API responded ${status}: ${body}","messagePattern":"recordOutcome: control API responded (.+?): (.+?)","errorType":"http","errorClass":"CavemanOutcomeError","httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":709,"sourceCode":"    observed_outcome: `${contract} ${stableStringify(input.values, \"values\")}`,\n    confidence,\n    evidence_refs: evidenceRefs,\n    occurred_at: occurredAt.toISOString(),\n  });\n\n  const doFetch: FetchLike = client.fetch ?? ((url, init) => globalFetch(url, init));\n  const response = await doFetch(\n    `${controlApiUrl}/api/v1/projects/${encodeURIComponent(projectId)}/outcomes`,\n    {\n      method: \"POST\",\n      headers: { \"content-type\": \"application/json\", authorization: `Bearer ${token}` },\n      body,\n    },\n  );\n\n  const text = await response.text();\n  const ok = response.ok ?? (response.status >= 200 && response.status < 300);\n  if (!ok) throw new CavemanOutcomeError(response.status, text);\n\n  let parsed: { data?: unknown; created?: unknown };\n  try {\n    parsed = JSON.parse(text) as { data?: unknown; created?: unknown };\n  } catch {\n    throw new CavemanOutcomeError(response.status, text);\n  }\n  return { status: response.status, created: parsed.created === true, record: parsed.data ?? null };\n}\n\nfunction globalFetch(url: string, init: RequestInitLike): Promise<ResponseLike> {\n  const fetchImpl = (globalThis as { fetch?: (u: string, i: unknown) => Promise<ResponseLike> }).fetch;\n  if (typeof fetchImpl !== \"function\") {\n    throw new Error(\"recordOutcome: no global fetch; pass client.fetch\");\n  }\n  return fetchImpl(url, init);\n}\n","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L691-L727","documentation":"Sentinel-style failure from the control-plane round trip in recordOutcome: the POST to {controlApiUrl}/api/v1/projects/{projectId}/outcomes returned a non-OK HTTP status. The interpolated values are the response status and body; the error is environmental (control API rejected or failed the request), not a local validation issue.","triggerScenarios":"Thrown at packages/mastra/src/index.ts:709 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the embedded status and body: 401/403 means bad CAVE token, 404 means wrong project id or URL, 422 means schema drift","Verify CAVE_CONTROL_URL and credentials are correct and retry after fixing","Upgrade the mastra package to match the control API version if the endpoint contract changed"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}