{"record":{"id":"55fc17ea189b7404","repo":"JuliusBrussee/caveman","slug":"recordoutcome-evidence-key-must-be-non-empty","errorCode":null,"errorMessage":"recordOutcome: evidence.${key} must be non-empty","messagePattern":"recordOutcome: evidence\\.(.+?) must be non-empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":664,"sourceCode":"  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]\");\n  }\n  if (typeof input.source !== \"string\" || !OUTCOME_SOURCES.has(input.source)) {\n    throw new Error(\"recordOutcome: source is required and must be one of ci|environment|database|business_event|human\");\n  }\n\n  const occurredAt = input.occurredAt === undefined ? new Date() : new Date(input.occurredAt);","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L646-L682","documentation":"After stringification, an evidence value must not be empty. In practice only the empty string triggers this: booleans and numbers always stringify to non-empty text ('false', '0'), and non-finite numbers are caught by an earlier check. So evidence: { note: '' } is the canonical case.","triggerScenarios":"An evidence entry whose value is the empty string — a field present in the template object but blank, e.g. { prUrl: '' }.","commonSituations":"Template objects filled from optional context where a key exists but its source value was blank; user input trimmed down to ''; optional chaining defaults of '' (pr?.url ?? '').","solutions":["Omit empty-string entries when building the evidence object","Or supply a meaningful non-empty value/placeholder for the key"],"exampleFix":"// before\nevidence: { prUrl: pr?.url ?? '' }\n\n// after\nevidence: ...(pr?.url ? { prUrl: pr.url } : {})","handlingStrategy":"validation","validationCode":"function evidenceStringsNonEmpty(evidence: Record<string, unknown>): boolean {\n  return Object.values(evidence).every((v) => typeof v !== 'string' || v.length > 0);\n}","typeGuard":"function isNonEmptyEvidenceString(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Filter out empty-string values when building evidence objects","Use conditional spread (...(url ? { url } : {})) instead of '' placeholders","Prefer omitting a key over sending it with a blank value"],"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"}