{"record":{"id":"c81149ade524b6db","repo":"mastra-ai/mastra","slug":"mastra-observability-storage-not-available","errorCode":"MASTRA_OBSERVABILITY_STORAGE_NOT_AVAILABLE","errorMessage":"Observability storage domain is not available","messagePattern":"Observability storage domain is not available","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"critical","filePath":"packages/core/src/evals/scoreTraces/scoreTracesWorkflow.ts","lineNumber":177,"sourceCode":"/** Resolve the target span for a trace/target pair. */\nasync function resolveTraceAndSpan({\n  storage,\n  target,\n}: {\n  storage: MastraStorage;\n  target: ScoreTraceTarget;\n}): Promise<{ trace: TraceRecord; span: SpanRecord }> {\n  if (!isScoreTraceReferenceTarget(target)) {\n    return {\n      trace: target.trace,\n      span: resolveTargetSpan({ trace: target.trace, spanId: target.spanId }),\n    };\n  }\n\n  // TODO: add storage api to get a single span\n  const observabilityStore = await storage.getStore('observability');\n  if (!observabilityStore) {\n    throw new MastraError({\n      id: 'MASTRA_OBSERVABILITY_STORAGE_NOT_AVAILABLE',\n      domain: ErrorDomain.STORAGE,\n      category: ErrorCategory.SYSTEM,\n      text: 'Observability storage domain is not available',\n    });\n  }\n  const trace = await observabilityStore.getTrace({ traceId: target.traceId });\n  if (!trace) {\n    throw new Error(`Trace not found for scoring, traceId: ${target.traceId}`);\n  }\n\n  return { trace, span: resolveTargetSpan({ trace, spanId: target.spanId }) };\n}\n\ntype TraceScoreResult = Awaited<ReturnType<MastraScorer['run']>>;\n\n/**\n * Run a scorer against an already-resolved trace + span.","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/scoreTraces/scoreTracesWorkflow.ts#L159-L195","documentation":"resolveTraceAndSpan needs the observability storage domain to fetch a trace by id. storage.getStore('observability') returned undefined — meaning no observability store is registered on the Mastra storage backend — so a MastraError (STORAGE/SYSTEM) is thrown. This is a configuration problem, not a data problem.","triggerScenarios":"Running the score-traces workflow with a { traceId } reference target while Mastra is configured with a storage adapter that does not provide an observability store (or storage not configured at all), so getStore('observability') yields undefined.","commonSituations":"Using a minimal/custom MastraStorage implementation without observability tables; storage configured without observability domain enabled; older storage adapter version predating the observability domain; pointing score-traces at a storage instance different from the one that persisted traces.","solutions":["Configure a storage adapter that supports the observability domain (e.g. @mastra/pg, @mastra/libsql with observability tables).","Verify mastra.setStorage()/Mastra({ storage }) is set before running the scoring workflow.","Confirm the storage backend's migrations ran so observability tables exist.","Ensure the same storage instance that captured the traces is the one scoring uses.","Upgrade the storage package if its version lacks getStore('observability')."],"exampleFix":"// before\nnew Mastra({ scorers }) // no storage\n// after\nimport { MastraStorage } from '@mastra/pg';\nnew Mastra({ scorers, storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }) });","handlingStrategy":"validation","validationCode":"// verify the observability store exists before scoring by trace reference\nconst store = await storage.getStore('observability');\nif (!store) throw new Error('Configure a storage adapter with an observability domain before score-traces');","typeGuard":"async function hasObservabilityStore(storage) {\n  return (await storage.getStore('observability')) != null;\n}","tryCatchPattern":"try {\n  await scoreTraces({ target: { traceId } });\n} catch (e) {\n  if (e?.id === 'MASTRA_OBSERVABILITY_STORAGE_NOT_AVAILABLE') {\n    throw new Error('Wire Mastra({ storage }) with an adapter supporting observability, e.g. @mastra/pg');\n  }\n  throw e;\n}","preventionTips":["Always configure Mastra({ storage }) with an adapter that supports the observability domain","Run storage migrations so observability tables exist","Assert getStore('observability') is non-null in app startup checks","Use the same storage instance for tracing and scoring"],"tags":["storage","observability","configuration","score-traces"],"backgroundTag":"storage-domain-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}