JuliusBrussee/caveman · error
recordOutcome: evidence.
Error message
recordOutcome: evidence.${key} must be a string, number, or boolean What it means
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.
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
Example fix
// before
evidence: { build: buildInfo, tags: tags }
// after
evidence: { buildId: buildInfo.id, tags: tags.join(',') } Defensive patterns
Strategy: validation
Validate before calling
function evidenceValuesScalar(evidence: Record<string, unknown>): boolean {
return Object.values(evidence).every(
(v) => typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean',
);
} Type guard
function isScalarEvidenceValue(v: unknown): v is string | number | boolean {
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean';
} Prevention
- 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
When it happens
Trigger: evidence: { build: { id: 7 } } or { tags: ['a', 'b'] } or { error: null } — any value whose typeof is object (or undefined).
Common situations: Dumping a parsed API response object or error payload straight into evidence; forgetting that JSON.parse produced nested structures; optional chaining producing undefined values.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- recordOutcome: evidence.
- recordOutcome: evidence keys must be non-empty
- recordOutcome: evidence must be a plain object
- recordOutcome: evidence must contain at least one reference
- recordOutcome: evidence.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/707b8445b9af22e7.
Report an issue: GitHub.
Appendix: source
Thrown at packages/mastra/src/index.ts:658
client: CavemanOutcomeClient,
input: RecordOutcomeInput,
): Promise<RecordOutcomeResult> {
const controlApiUrl = requireBaseUrl(client.controlApiUrl, "recordOutcome: controlApiUrl");
const token = requireNonEmpty(client.token, "recordOutcome: token");
const projectId = requireNonEmpty(client.projectId, "recordOutcome: projectId");
const taskId = requireNonEmpty(input.taskId, "recordOutcome: taskId");
const contract = requireNonEmpty(input.contract, "recordOutcome: contract");
if (!isPlainObject(input.values) || Object.keys(input.values).length === 0) {
throw new Error("recordOutcome: values must be a non-empty plain object");
}
if (!isPlainObject(input.evidence)) {
throw new Error("recordOutcome: evidence must be a plain object");
}
const evidenceRefs = Object.entries(input.evidence).map(([key, value]) => {
if (!key.trim()) throw new Error("recordOutcome: evidence keys must be non-empty");
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
throw new Error(`recordOutcome: evidence.${key} must be a string, number, or boolean`);
}
if (typeof value === "number" && !Number.isFinite(value)) {
throw new Error(`recordOutcome: evidence.${key} must be a finite number`);
}
const ref = `${key}:${String(value)}`;
if (!ref.slice(key.length + 1)) throw new Error(`recordOutcome: evidence.${key} must be non-empty`);
return ref;
});
if (evidenceRefs.length === 0) {
throw new Error("recordOutcome: evidence must contain at least one reference");
}
if (evidenceRefs.length > MAX_EVIDENCE_REFS) {
throw new Error(`recordOutcome: evidence must contain at most ${MAX_EVIDENCE_REFS} references`);
}
const confidence = input.confidence;
if (typeof confidence !== "number" || !Number.isFinite(confidence) || confidence < 0 || confidence > 1) {
throw new Error("recordOutcome: confidence is required and must be a number within [0,1]");View on GitHub (pinned to 766dce6b13)