JuliusBrussee/caveman · error
recordOutcome: occurredAt must be a valid date
Error message
recordOutcome: occurredAt must be a valid date
What it means
Thrown by recordOutcome in the Mastra integration when the outcome input's occurredAt field is not a valid date (missing, non-string, or unparseable). It fires after the evidence-reference and confidence checks, as part of the input validation chain.
Solutions
- Pass occurredAt as an ISO 8601 string or a Date instance
- Validate with !Number.isNaN(Date.parse(value)) before calling recordOutcome
- Omit the field if the API allows defaulting to the current time
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/mastra/src/index.ts:684 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/70767b64ae446548.
Report an issue: GitHub.
Appendix: source
Thrown at packages/mastra/src/index.ts:684
});
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]");
}
if (typeof input.source !== "string" || !OUTCOME_SOURCES.has(input.source)) {
throw new Error("recordOutcome: source is required and must be one of ci|environment|database|business_event|human");
}
const occurredAt = input.occurredAt === undefined ? new Date() : new Date(input.occurredAt);
if (Number.isNaN(occurredAt.getTime())) {
throw new Error("recordOutcome: occurredAt must be a valid date");
}
const body = JSON.stringify({
correlation_kind: "task",
correlation_id: taskId,
source: input.source,
observed_outcome: `${contract} ${stableStringify(input.values, "values")}`,
confidence,
evidence_refs: evidenceRefs,
occurred_at: occurredAt.toISOString(),
});
const doFetch: FetchLike = client.fetch ?? ((url, init) => globalFetch(url, init));
const response = await doFetch(
`${controlApiUrl}/api/v1/projects/${encodeURIComponent(projectId)}/outcomes`,
{
method: "POST",
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },View on GitHub (pinned to 766dce6b13)