{"record":{"id":"979cb80f11c5e9a6","repo":"JuliusBrussee/caveman","slug":"path-must-be-a-finite-number","errorCode":null,"errorMessage":"${path} must be a finite number","messagePattern":"(.+?) must be a finite number","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":742,"sourceCode":"  }\n  return fetchImpl(url, init);\n}\n\n/**\n * JSON with object keys sorted at every level. Throws on anything that is not a\n * plain object, array, string, finite number, boolean, or null — a Date, a Map,\n * or a class instance would serialize into something the caller did not mean,\n * and the record's digest is its identity.\n */\nexport function stableStringify(value: unknown, path = \"value\"): string {\n  if (value === null) return \"null\";\n  switch (typeof value) {\n    case \"string\":\n      return JSON.stringify(value);\n    case \"boolean\":\n      return value ? \"true\" : \"false\";\n    case \"number\":\n      if (!Number.isFinite(value)) throw new Error(`${path} must be a finite number`);\n      return JSON.stringify(value);\n    case \"object\": {\n      if (Array.isArray(value)) {\n        return `[${value.map((item, i) => stableStringify(item, `${path}[${i}]`)).join(\",\")}]`;\n      }\n      if (!isPlainObject(value)) throw new Error(`${path} must be a plain object, array, or primitive`);\n      const entries = Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n      return `{${entries\n        .map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item, `${path}.${key}`)}`)\n        .join(\",\")}}`;\n    }\n    default:\n      throw new Error(`${path} must be JSON data (got ${typeof value})`);\n  }\n}\n\n// ---------------------------------------------------------------------------\n// 5. Deep links","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/mastra/src/index.ts#L724-L760","documentation":"Guard inside stableStringify: a number encountered at the given path is not finite (NaN, Infinity, -Infinity). Because the stringified record's digest is its identity, non-finite numbers are refused rather than serialized to 'null'.","triggerScenarios":"Thrown at packages/mastra/src/index.ts:742 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Find the value at the reported path and replace NaN/Infinity with a finite number or null","Sanitize input data before building the record (e.g. filter with Number.isFinite)","Fix upstream computation that produced the non-finite number (division by zero, parse failure)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}