{"record":{"id":"a042615d75558b52","repo":"mastra-ai/mastra","slug":"storage-not-configured","errorCode":null,"errorMessage":"Storage not configured","messagePattern":"Storage not configured","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/datasets.ts","lineNumber":619,"sourceCode":"// ============================================================================\n\nexport const LIST_ALL_EXPERIMENTS_ROUTE = createRoute({\n  method: 'GET',\n  path: '/experiments',\n  responseType: 'json',\n  queryParamSchema: listExperimentsQuerySchema,\n  responseSchema: listExperimentsResponseSchema,\n  summary: 'List all experiments',\n  description: 'Returns a paginated list of all experiments across all datasets',\n  tags: ['Experiments'],\n  requiresAuth: true,\n  handler: async ({ mastra, ...params }) => {\n    assertDatasetsAvailable();\n    try {\n      const { page, perPage, experimentSetId, comparisonId, variantId, trialIndex } = params;\n      const storage = mastra.getStorage();\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage not configured' });\n      }\n      const experimentsStore = await storage.getStore('experiments');\n      if (!experimentsStore) {\n        throw new HTTPException(500, { message: 'Experiments storage not available' });\n      }\n      const result = await experimentsStore.listExperiments({\n        experimentSetId,\n        comparisonId,\n        variantId,\n        trialIndex,\n        pagination: { page: page ?? 0, perPage: perPage ?? 20 },\n      });\n      return { experiments: result.experiments, pagination: result.pagination };\n    } catch (error) {\n      if (error instanceof MastraError) {\n        throw new HTTPException(getHttpStatusForMastraError(error.id) as StatusCode, { message: error.message });\n      }\n      return handleError(error, 'Error listing experiments');","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/datasets.ts#L601-L637","documentation":"HTTP 500 thrown by the list-experiments handler when mastra.getStorage() returns undefined, meaning the Mastra instance has no storage configured. Experiments are persisted through the storage layer's experiments store, so without storage the endpoint cannot serve results. A sibling 500 ('Experiments storage not available') is thrown if storage exists but lacks an experiments store.","triggerScenarios":"GET /api/datasets/:datasetId/experiments (list/compare/review routes) against a Mastra instance constructed without a storage option, e.g. `new Mastra({ ... })` with no `storage:` entry.","commonSituations":"Running Mastra in dev/in-memory mode and then calling experiments endpoints; forgetting to add storage (LibSQL/Postgres/upstash) to mastra config; storage configured but the storage package version predates the experiments store; env-gated storage config not set in the deployment.","solutions":["Configure storage on the Mastra instance, e.g. new Mastra({ storage: new LibSQLStore({ url: 'file:./mastra.db' }) }).","Verify the storage backend supports the experiments store — upgrade @mastra/storage (or the chosen adapter) to a version that includes it.","Check deployment env vars so the storage URL/connection is present where the server runs.","If experiments are intentionally unused, stop calling the experiments endpoints or feature-flag them client-side."],"exampleFix":"// before\nexport const mastra = new Mastra({ agents: { myAgent } });\n// after\nimport { LibSQLStore } from '@mastra/libsql';\nexport const mastra = new Mastra({\n  agents: { myAgent },\n  storage: new LibSQLStore({ url: process.env.MASTRA_STORAGE_URL ?? 'file:./mastra.db' }),\n});","handlingStrategy":"validation","validationCode":"const storage = mastra.getStorage();\nif (!storage) throw new Error('Mastra instance has no storage configured; experiments endpoints unavailable');\nconst store = await storage.getStore('experiments');\nif (!store) throw new Error('Storage backend does not support the experiments store; upgrade the adapter');","typeGuard":"function hasExperimentsStorage(mastra: { getStorage(): unknown }): boolean {\n  return Boolean(mastra.getStorage());\n}","tryCatchPattern":"try {\n  const experiments = await api.listExperiments(datasetId);\n} catch (e) {\n  if ((e as any)?.status === 500 && /Storage not configured/.test((e as any)?.message ?? '')) {\n    console.error('Configure storage on the Mastra instance to use experiments');\n    return [];\n  }\n  throw e;\n}","preventionTips":["Always pass a storage adapter when constructing Mastra if you use experiments/datasets.","Verify env vars for the storage URL exist in every deployment environment.","Use a storage adapter version that implements the experiments store; check getStore('experiments') at startup.","Feature-flag experiments UI when storage is intentionally absent (e.g. ephemeral dev mode)."],"tags":["http-500","storage","configuration","experiments","mastra"],"backgroundTag":"storage-not-configured","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}