JuliusBrussee/caveman · error

recordOutcome: evidence.

Error message

recordOutcome: evidence.${key} must be non-empty

What it means

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.

Solutions

  1. Omit empty-string entries when building the evidence object
  2. Or supply a meaningful non-empty value/placeholder for the key

Example fix

// before
evidence: { prUrl: pr?.url ?? '' }

// after
evidence: ...(pr?.url ? { prUrl: pr.url } : {})
Defensive patterns

Strategy: validation

Validate before calling

function evidenceStringsNonEmpty(evidence: Record<string, unknown>): boolean {
  return Object.values(evidence).every((v) => typeof v !== 'string' || v.length > 0);
}

Type guard

function isNonEmptyEvidenceString(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0;
}

Prevention

When it happens

Trigger: An evidence entry whose value is the empty string — a field present in the template object but blank, e.g. { prUrl: '' }.

Common situations: 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 ?? '').

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


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/55fc17ea189b7404. Report an issue: GitHub.

Appendix: source

Thrown at packages/mastra/src/index.ts:664

  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]");
  }
  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);

View on GitHub (pinned to 766dce6b13)