{"record":{"id":"b6c204361b2ddf65","repo":"JuliusBrussee/caveman","slug":"recordoutcome-evidence-must-be-a-plain-object","errorCode":null,"errorMessage":"recordOutcome: evidence must be a plain object","messagePattern":"recordOutcome: evidence must be a plain object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":653,"sourceCode":" * confidence outside [0,1], or values that are not plain JSON. Exactly one\n * request is made — no retries — and a non-2xx response throws a\n * {@link CavemanOutcomeError} carrying the status and body verbatim.\n */\nexport async function recordOutcome(\n  client: CavemanOutcomeClient,\n  input: RecordOutcomeInput,\n): Promise<RecordOutcomeResult> {\n  const controlApiUrl = requireBaseUrl(client.controlApiUrl, \"recordOutcome: controlApiUrl\");\n  const token = requireNonEmpty(client.token, \"recordOutcome: token\");\n  const projectId = requireNonEmpty(client.projectId, \"recordOutcome: projectId\");\n  const taskId = requireNonEmpty(input.taskId, \"recordOutcome: taskId\");\n  const contract = requireNonEmpty(input.contract, \"recordOutcome: contract\");\n\n  if (!isPlainObject(input.values) || Object.keys(input.values).length === 0) {\n    throw new Error(\"recordOutcome: values must be a non-empty plain object\");\n  }\n  if (!isPlainObject(input.evidence)) {\n    throw new Error(\"recordOutcome: evidence must be a plain object\");\n  }\n  const evidenceRefs = Object.entries(input.evidence).map(([key, value]) => {\n    if (!key.trim()) throw new Error(\"recordOutcome: evidence keys must be non-empty\");\n    if (typeof value !== \"string\" && typeof value !== \"number\" && typeof value !== \"boolean\") {\n      throw new Error(`recordOutcome: evidence.${key} must be a string, number, or boolean`);\n    }\n    if (typeof value === \"number\" && !Number.isFinite(value)) {\n      throw new Error(`recordOutcome: evidence.${key} must be a finite number`);\n    }\n    const ref = `${key}:${String(value)}`;\n    if (!ref.slice(key.length + 1)) throw new Error(`recordOutcome: evidence.${key} must be non-empty`);\n    return ref;\n  });\n  if (evidenceRefs.length === 0) {\n    throw new Error(\"recordOutcome: evidence must contain at least one reference\");\n  }\n  if (evidenceRefs.length > MAX_EVIDENCE_REFS) {\n    throw new Error(`recordOutcome: evidence must contain at most ${MAX_EVIDENCE_REFS} references`);","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/mastra/src/index.ts#L635-L671","documentation":"The evidence field of recordOutcome must be a plain object whose entries become 'key:value' reference strings attached to the outcome. This specific error fires when evidence is not a plain object at all — arrays, null, undefined, strings, or class instances all fail isPlainObject. It is the shape check that runs before per-key validation.","triggerScenarios":"recordOutcome(client, { ..., evidence: null }), evidence: ['commit:abc'], evidence: 'commit:abc', or evidence: new EvidenceMap() (class instance).","commonSituations":"Optional evidence left null when a run has no evidence, reusing an array 'pairs' structure from elsewhere in the codebase, or TS types bypassed with `as any` letting a non-object through.","solutions":["Pass a plain object with string/number/boolean values: evidence: { commit: sha }.","If evidence is genuinely absent, the API still requires the object shape — check whether your contract permits a placeholder reference before sending.","Replace class instances with plain object literals (or convert via structured cloning) before calling."],"exampleFix":"// before\nawait recordOutcome(client, { taskId, contract, values, evidence: null });\n// after\nawait recordOutcome(client, { taskId, contract, values, evidence: { commit: sha } });","handlingStrategy":"validation","validationCode":"function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === \"object\" && v !== null && !Array.isArray(v)\n    && Object.getPrototypeOf(v) === Object.prototype;\n}\n// require isPlainObject(input.evidence) before calling recordOutcome","typeGuard":"function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === \"object\" && v !== null && !Array.isArray(v)\n    && Object.getPrototypeOf(v) === Object.prototype;\n}","tryCatchPattern":"try {\n  await recordOutcome(client, input);\n} catch (e) {\n  if (e instanceof Error && e.message === \"recordOutcome: evidence must be a plain object\") {\n    input.evidence = { note: \"none\" }; // repair shape, then retry once\n    return recordOutcome(client, input);\n  }\n  throw e;\n}","preventionTips":["Type evidence as Record<string, string | number | boolean> in your code.","Default evidence to a plain object literal, never null or an array.","Convert class instances/Maps to plain objects before building the payload."],"tags":["validation","api","telemetry"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}