{"record":{"id":"ebc29f2e8bf4edc8","repo":"mastra-ai/mastra","slug":"storage-is-not-configured-ebc29f","errorCode":null,"errorMessage":"Storage is not configured","messagePattern":"Storage is not configured","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/stored-prompt-blocks.ts","lineNumber":59,"sourceCode":"/**\n * GET /stored/prompt-blocks - List all stored prompt blocks\n */\nexport const LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({\n  method: 'GET',\n  path: '/stored/prompt-blocks',\n  responseType: 'json',\n  queryParamSchema: listStoredPromptBlocksQuerySchema,\n  responseSchema: listStoredPromptBlocksResponseSchema,\n  summary: 'List stored prompt blocks',\n  description: 'Returns a paginated list of all prompt blocks stored in the database',\n  tags: ['Stored Prompt Blocks'],\n  requiresAuth: true,\n  handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata, requestContext }) => {\n    try {\n      const storage = mastra.getStorage();\n\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage is not configured' });\n      }\n\n      const promptBlockStore = await storage.getStore('promptBlocks');\n      if (!promptBlockStore) {\n        throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n      }\n\n      const scope = await getStoredResourceScope(mastra, requestContext);\n      const result = await promptBlockStore.listResolved({\n        page,\n        perPage,\n        orderBy,\n        status,\n        authorId,\n        metadata: scopeStoredResourceMetadata(metadata, scope),\n      });\n\n      // For each block, fetch the latest version to compute hasDraft.","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-prompt-blocks.ts#L41-L77","documentation":"The stored-prompt-blocks list handler requires storage; mastra.getStorage() returned undefined so the server throws HTTP 500. Persisted prompt blocks are only available when a storage backend is attached to the Mastra instance.","triggerScenarios":"GET request to the stored prompt blocks collection endpoint on a Mastra instance created without a storage option, or where storage was not registered in the config the server booted with.","commonSituations":"Fresh project following quickstart that skips storage setup; server deployed without database env vars; Mastra instance built conditionally so the storage branch never runs (e.g. wrong NODE_ENV check).","solutions":["Attach storage: new Mastra({ storage: new MastraLibsql({ url: 'file:./mastra.db' }) }) or another supported adapter","Ensure the database connection env vars are set in the environment running the server","Log mastra.getStorage() at boot to confirm it is non-null before serving requests"],"exampleFix":"// before\nexport const mastra = new Mastra({ agents });\n// after\nexport const mastra = new Mastra({\n  agents,\n  storage: new MastraLibsql({ url: process.env.LIBSQL_URL ?? 'file:./mastra.db' }),\n});","handlingStrategy":"validation","validationCode":"if (!mastra.getStorage()) {\n  throw new Error('No storage configured; prompt blocks require a storage backend');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch('/api/stored-prompt-blocks?page=0&perPage=10');\n  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);\n} catch (e) {\n  if (/Storage is not configured/.test(String(e))) {\n    // attach storage to the Mastra instance and restart\n  }\n}","preventionTips":["Configure storage before exposing server routes","Boot-time assertion for getStorage()","Keep DB env vars in all deploy environments","Validate setup with a single list request after boot"],"tags":["http-500","storage","configuration","prompt-blocks"],"backgroundTag":"missing-storage-configuration","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}