{"record":{"id":"f45dacbe0b8cc6b0","repo":"JuliusBrussee/caveman","slug":"recordoutcome-evidence-key-must-be-a-finite-nu","errorCode":null,"errorMessage":"recordOutcome: evidence.${key} must be a finite number","messagePattern":"recordOutcome: evidence\\.(.+?) must be a finite number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":661,"sourceCode":"  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]\");\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\");","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L643-L679","documentation":"Numeric evidence values must be finite. NaN and ±Infinity are rejected per-key because they serialize to invalid JSON numbers (NaN is not representable in JSON) and would corrupt the stored 'key:value' reference on the platform.","triggerScenarios":"evidence: { score: NaN } or { ratio: Infinity } — typically the result of dividing by zero, or parseFloat on a non-numeric string.","commonSituations":"Computing rates/averages from counters that were zero; parseFloat('') yielding NaN; downstream missing data feeding a computed metric.","solutions":["Guard computed metrics before including them: Number.isFinite(x) ? x : 0 — or omit the entry","Fix the upstream math: guard divide-by-zero, validate parseFloat inputs"],"exampleFix":"// before\nevidence: { durationSec: elapsed / count } // count === 0 -> Infinity\n\n// after\nevidence: { durationSec: count > 0 ? elapsed / count : 0 }","handlingStrategy":"validation","validationCode":"function evidenceNumbersFinite(evidence: Record<string, unknown>): boolean {\n  return Object.values(evidence).every((v) => typeof v !== 'number' || Number.isFinite(v));\n}","typeGuard":"function isFiniteEvidenceNumber(v: unknown): v is number {\n  return typeof v === 'number' && Number.isFinite(v);\n}","tryCatchPattern":null,"preventionTips":["Guard divisions and rate computations with zero-denominator checks","Validate parseFloat results with Number.isFinite before use","Omit metrics whose inputs are missing rather than sending NaN/Infinity"],"tags":["validation","evidence","numbers","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"}