{"record":{"id":"707b8445b9af22e7","repo":"JuliusBrussee/caveman","slug":"recordoutcome-evidence-key-must-be-a-string-n","errorCode":null,"errorMessage":"recordOutcome: evidence.${key} must be a string, number, or boolean","messagePattern":"recordOutcome: evidence\\.(.+?) must be a string, number, or boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":658,"sourceCode":"  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`);\n  }\n\n  const confidence = input.confidence;\n  if (typeof confidence !== \"number\" || !Number.isFinite(confidence) || confidence < 0 || confidence > 1) {\n    throw new Error(\"recordOutcome: confidence is required and must be a number within [0,1]\");","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L640-L676","documentation":"Evidence values may only be string, number, or boolean — each is stringified into a 'key:value' text reference. Nested objects, arrays, null, and undefined have no faithful scalar representation and are rejected per-key, with the offending key named in the message.","triggerScenarios":"evidence: { build: { id: 7 } } or { tags: ['a', 'b'] } or { error: null } — any value whose typeof is object (or undefined).","commonSituations":"Dumping a parsed API response object or error payload straight into evidence; forgetting that JSON.parse produced nested structures; optional chaining producing undefined values.","solutions":["Flatten nested data to scalar fields: { buildId: build.id }","Join arrays into a string: { tags: tags.join(',') }","Drop null/undefined entries entirely rather than passing them"],"exampleFix":"// before\nevidence: { build: buildInfo, tags: tags }\n\n// after\nevidence: { buildId: buildInfo.id, tags: tags.join(',') }","handlingStrategy":"validation","validationCode":"function evidenceValuesScalar(evidence: Record<string, unknown>): boolean {\n  return Object.values(evidence).every(\n    (v) => typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean',\n  );\n}","typeGuard":"function isScalarEvidenceValue(v: unknown): v is string | number | boolean {\n  return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["Flatten nested objects into scalar fields before recording","Join arrays with Array.join rather than passing them raw","Omit null/undefined entries when assembling evidence"],"tags":["validation","evidence","api-misuse","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"}