JuliusBrussee/caveman · error

must be JSON data (got )

Error message

${path} must be JSON data (got ${typeof value})

What it means

Fallback branch of stableStringify's switch: the value at the given path has a typeof that is not JSON-serializable (function, symbol, undefined, bigint). It can never produce a stable JSON representation, so it is rejected.

Solutions

  1. Remove functions, symbols, undefined, and bigint values from the payload before stringify
  2. Convert bigint to string or number explicitly
  3. JSON.stringify the payload first or use structuredClone to surface non-serializable fields early
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/mastra/src/index.ts:755 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/00292ee0eeed458f. Report an issue: GitHub.

Appendix: source

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

    case "string":
      return JSON.stringify(value);
    case "boolean":
      return value ? "true" : "false";
    case "number":
      if (!Number.isFinite(value)) throw new Error(`${path} must be a finite number`);
      return JSON.stringify(value);
    case "object": {
      if (Array.isArray(value)) {
        return `[${value.map((item, i) => stableStringify(item, `${path}[${i}]`)).join(",")}]`;
      }
      if (!isPlainObject(value)) throw new Error(`${path} must be a plain object, array, or primitive`);
      const entries = Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
      return `{${entries
        .map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item, `${path}.${key}`)}`)
        .join(",")}}`;
    }
    default:
      throw new Error(`${path} must be JSON data (got ${typeof value})`);
  }
}

// ---------------------------------------------------------------------------
// 5. Deep links
// ---------------------------------------------------------------------------

/**
 * Mastra Studio's documented default address. The dev server listens on 4111
 * (or `PORT`): https://mastra.ai/docs/studio/overview
 */
export const MASTRA_STUDIO_DEFAULT_BASE_URL = "http://localhost:4111";

export interface MastraStudioLinkOptions {
  /**
   * REQUIRED. Mastra documents a Studio Observability tab but not a per-trace
   * URL, so this package will not invent one. Supply the shape your Studio
   * build uses, with `{traceId}` (and optionally `{baseUrl}`) placeholders —

View on GitHub (pinned to 766dce6b13)