{"record":{"id":"444b7e4c68918c28","repo":"mastra-ai/mastra","slug":"storage-not-configured-configure-storage-in-mastr","errorCode":null,"errorMessage":"Storage not configured. Configure storage in Mastra instance.","messagePattern":"Storage not configured\\. Configure storage in Mastra instance\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/datasets/experiment/analytics/compare.ts","lineNumber":62,"sourceCode":" *   thresholds: {\n *     'accuracy': { value: 0.05, direction: 'higher-is-better' },\n *     'latency': { value: 100, direction: 'lower-is-better' },\n *   },\n * });\n *\n * if (result.hasRegression) {\n *   console.log('Quality regression detected!');\n * }\n * ```\n */\nexport async function compareExperiments(mastra: Mastra, config: CompareExperimentsConfig): Promise<ComparisonResult> {\n  const { experimentIdA, experimentIdB, thresholds = {} } = config;\n  const warnings: string[] = [];\n\n  // 1. Get storage\n  const storage = mastra.getStorage();\n  if (!storage) {\n    throw new Error('Storage not configured. Configure storage in Mastra instance.');\n  }\n\n  const experimentsStore = await storage.getStore('experiments');\n  const scoresStore = await storage.getStore('scores');\n\n  if (!experimentsStore) {\n    throw new Error('ExperimentsStorage not configured.');\n  }\n  if (!scoresStore) {\n    throw new Error('ScoresStorage not configured.');\n  }\n\n  // 2. Load both experiments\n  const [experimentA, experimentB] = await Promise.all([\n    experimentsStore.getExperimentById({ id: experimentIdA }),\n    experimentsStore.getExperimentById({ id: experimentIdB }),\n  ]);\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/experiment/analytics/compare.ts#L44-L80","documentation":"compareExperiments compares score data of two experiments, which requires a configured storage backend on the Mastra instance. If mastra.getStorage() returns undefined, no storage was configured and comparison cannot proceed.","triggerScenarios":"Calling compareExperiments(config) with a Mastra instance constructed without a storage option, or before storage is attached.","commonSituations":"Forgetting to pass storage in new Mastra({...}); running analytics in a test/dev environment with in-memory-only setup; storage config gated behind env vars that are unset in the deployment.","solutions":["Configure storage on the Mastra instance, e.g. new Mastra({ storage: new MastraStorage(...) })","Check mastra.getStorage() before calling compareExperiments and surface a clear config error","Verify the storage dependency/package is installed and imported correctly","Ensure env vars controlling storage config are set in the runtime environment"],"exampleFix":"// before\nconst mastra = new Mastra({ agents: {...} }); // no storage\ncompareExperiments({ mastra, ... });\n// after\nconst mastra = new Mastra({ agents: {...}, storage: new LibSQLStore({ url: process.env.DB_URL }) });","handlingStrategy":"validation","validationCode":"const storage = mastra.getStorage();\nif (!storage) throw new Error('Configure storage on the Mastra instance before comparing experiments');","typeGuard":"function hasStorage(mastra) { return typeof mastra.getStorage === 'function' && mastra.getStorage() != null; }","tryCatchPattern":"try {\n  const report = await compareExperiments({ mastra, config });\n} catch (e) {\n  if (e instanceof Error && /Storage not configured/i.test(e.message)) {\n    // reconfigure Mastra with a storage backend and retry\n  } else throw e;\n}","preventionTips":["Always pass storage when constructing Mastra if you use datasets/experiments","Assert storage presence once at app startup, not at point of use","Keep storage config env-driven and validated on boot"],"tags":["storage","configuration","experiments","analytics"],"backgroundTag":"missing-env-var","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}