{"record":{"id":"094e38177c174dbf","repo":"mastra-ai/mastra","slug":"unable-to-locate-pricing-data-jsonl-at-any-known-p","errorCode":null,"errorMessage":"Unable to locate pricing data JSONL at any known path: ${candidates.join(', ')}","messagePattern":"Unable to locate pricing data JSONL at any known path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"observability/mastra/src/metrics/pricing-registry.ts","lineNumber":180,"sourceCode":"  });\n}\n\nfunction resolvePricingModelPath(): string {\n  const packageRoot = getPackageRoot();\n  const candidates = [\n    path.join(packageRoot, 'dist', 'metrics', DATA_FILE_NAME),\n    path.join(packageRoot, 'src', 'metrics', DATA_FILE_NAME),\n    path.join(process.cwd(), 'observability', 'mastra', 'src', 'metrics', DATA_FILE_NAME),\n    path.join(process.cwd(), 'src', 'metrics', DATA_FILE_NAME),\n  ];\n\n  for (const candidate of candidates) {\n    if (fs.existsSync(candidate)) {\n      return candidate;\n    }\n  }\n\n  throw new Error(`Unable to locate pricing data JSONL at any known path: ${candidates.join(', ')}`);\n}\n\nfunction getPackageRoot(): string {\n  try {\n    const require = createRequire(import.meta.url || 'file://');\n    const packageJsonPath = require.resolve('@mastra/observability/package.json');\n    return path.dirname(packageJsonPath);\n  } catch {\n    return process.cwd();\n  }\n}\n\nfunction makePricingKey(args: { provider: string; model: string }): string {\n  return `${normalizeKeyPart(args.provider)}::${normalizeKeyPart(args.model)}`;\n}\n\nfunction normalizeKeyPart(value: string): string {\n  return value.trim().toLowerCase();","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/observability/mastra/src/metrics/pricing-registry.ts#L162-L198","documentation":"resolvePricingModelPath probes a list of known filesystem locations (package root, workspace, relative paths) to find the LLM pricing JSONL data file shipped with @mastra/observability. If none of the candidate paths exists on disk, it throws. This almost always means a broken/partial install or running from an unexpected working directory/build layout.","triggerScenarios":"Creating a cost/pricing metric (pricing-registry `content` accessor) when the pricing JSONL file is missing from every candidate path — e.g. package published without bundled data files, monorepo build that skipped copying assets, or npm/pnpm install that pruned files.","commonSituations":"Installing from a registry mirror or pack that drops .jsonl assets; running tests from a bundle (esbuild/webpack) that didn't include the data file; developing inside the monorepo before building @mastra/observability; exotic package managers (Bun/Deno npm compat) resolving package.json differently.","solutions":["Reinstall/clean-rebuild @mastra/observability (pnpm install; rebuild the package) so the pricing JSONL ships with node_modules.","Verify the file exists at node_modules/@mastra/observability/ (search for *.jsonl); if missing, the package or bundler is dropping assets — fix the build's asset-copy step.","If bundling, mark the JSONL as an external asset or copy it and point the resolver at a known path via the supported candidates.","Check you're not using an unofficial/patched package version that omits the data file; upgrade to a released version."],"exampleFix":"// before: bundler stripped data files\n// after: esbuild config keeps the asset resolvable\nexport default {\n  external: ['@mastra/observability'],\n  loader: { '.jsonl': 'file' },\n};","handlingStrategy":"validation","validationCode":"import { createRequire } from 'node:module';\nimport { existsSync } from 'node:fs';\nconst req = createRequire(import.meta.url);\nconst pkgRoot = req.resolve('@mastra/observability/package.json');\nconst hasPricingData = existsSync(require('node:path').join(require('node:path').dirname(pkgRoot), 'metrics')) \n  || existsSync('./metrics/llm-pricing.jsonl');\nif (!hasPricingData) throw new Error('Pricing JSONL missing; reinstall @mastra/observability before initializing cost metrics');","typeGuard":"function pricingFileExists(paths: string[]): boolean {\n  return paths.some((p) => existsSync(p));\n}","tryCatchPattern":"try {\n  costMetric.enable();\n} catch (err) {\n  if (String(err.message).includes('Unable to locate pricing data JSONL')) {\n    console.error('Reinstall @mastra/observability — pricing data file missing');\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["Verify node_modules/@mastra/observability contains its *.jsonl assets after install.","If bundling, copy/exclude .jsonl data files from the bundle pipeline.","Don't use registry mirrors or pack tools that strip non-JS assets.","Build workspace packages before running tests in the monorepo."],"tags":["filesystem","configuration","missing-file","observability"],"backgroundTag":"missing-data-file","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}