{"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/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L635-L671","documentation":"The evidence field of recordOutcome must be a plain object mapping reference keys to scalar values (e.g. { commit: 'abc123', suiteId: 42 }). The implementation iterates Object.entries over it to build evidence references, so null, arrays, strings, numbers, and class instances are rejected before any network call.","triggerScenarios":"recordOutcome(client, { ..., evidence: null }) or evidence: [] or evidence: 'commit:abc123' — anything that is not a plain object.","commonSituations":"An optional evidence builder returning null when nothing was collected; spreading a JSON-parsed value that was null; config defaults of null flowing into the call.","solutions":["Pass an object literal with at least one entry: evidence: { commit: sha }","Default null/undefined to a populated object before the call: evidence ?? { commit: 'unknown' }","Type the payload so TypeScript rejects non-object evidence at compile time"],"exampleFix":"// before\nrecordOutcome(client, { taskId, contract, values, evidence: null });\n\n// after\nrecordOutcome(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 &&\n    (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);\n}","typeGuard":"function isEvidenceObject(v: unknown): v is Record<string, string | number | boolean> {\n  return isPlainObject(v);\n}","tryCatchPattern":null,"preventionTips":["Default absent evidence to a populated object, never null/undefined","Type evidence as Record<string, string | number | boolean>","Filter/normalize collector output before passing it as evidence"],"tags":["validation","api-misuse","evidence","mastra"],"backgroundTag":"schema-validation-failed","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"}