JuliusBrussee/caveman · error

${path} must be a finite number

Error message

${path} must be a finite number

What it means

Error "${path} must be a finite number" thrown in JuliusBrussee/caveman.

Source

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

  }
  return fetchImpl(url, init);
}

/**
 * JSON with object keys sorted at every level. Throws on anything that is not a
 * plain object, array, string, finite number, boolean, or null — a Date, a Map,
 * or a class instance would serialize into something the caller did not mean,
 * and the record's digest is its identity.
 */
export function stableStringify(value: unknown, path = "value"): string {
  if (value === null) return "null";
  switch (typeof value) {
    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

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Pass a finite number at the indicated path.

When it happens

Trigger: Thrown at packages/mastra/src/index.ts:742 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/979cb80f11c5e9a6. Report an issue: GitHub.