JuliusBrussee/caveman · error · CavemanOutcomeError
recordOutcome: control API responded
Error message
recordOutcome: control API responded ${status}: ${body} What it means
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.
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at packages/mastra/src/index.ts:709 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/4f125d64953a830d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/mastra/src/index.ts:709
observed_outcome: `${contract} ${stableStringify(input.values, "values")}`,
confidence,
evidence_refs: evidenceRefs,
occurred_at: occurredAt.toISOString(),
});
const doFetch: FetchLike = client.fetch ?? ((url, init) => globalFetch(url, init));
const response = await doFetch(
`${controlApiUrl}/api/v1/projects/${encodeURIComponent(projectId)}/outcomes`,
{
method: "POST",
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
body,
},
);
const text = await response.text();
const ok = response.ok ?? (response.status >= 200 && response.status < 300);
if (!ok) throw new CavemanOutcomeError(response.status, text);
let parsed: { data?: unknown; created?: unknown };
try {
parsed = JSON.parse(text) as { data?: unknown; created?: unknown };
} catch {
throw new CavemanOutcomeError(response.status, text);
}
return { status: response.status, created: parsed.created === true, record: parsed.data ?? null };
}
function globalFetch(url: string, init: RequestInitLike): Promise<ResponseLike> {
const fetchImpl = (globalThis as { fetch?: (u: string, i: unknown) => Promise<ResponseLike> }).fetch;
if (typeof fetchImpl !== "function") {
throw new Error("recordOutcome: no global fetch; pass client.fetch");
}
return fetchImpl(url, init);
}
View on GitHub (pinned to 766dce6b13)