mastra-ai/mastra · error · HTTPException

Storage is not configured

Error message

Storage is not configured

What it means

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.

Source

Thrown at packages/server/src/server/handlers/stored-prompt-blocks.ts:59

/**
 * GET /stored/prompt-blocks - List all stored prompt blocks
 */
export const LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({
  method: 'GET',
  path: '/stored/prompt-blocks',
  responseType: 'json',
  queryParamSchema: listStoredPromptBlocksQuerySchema,
  responseSchema: listStoredPromptBlocksResponseSchema,
  summary: 'List stored prompt blocks',
  description: 'Returns a paginated list of all prompt blocks stored in the database',
  tags: ['Stored Prompt Blocks'],
  requiresAuth: true,
  handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata, requestContext }) => {
    try {
      const storage = mastra.getStorage();

      if (!storage) {
        throw new HTTPException(500, { message: 'Storage is not configured' });
      }

      const promptBlockStore = await storage.getStore('promptBlocks');
      if (!promptBlockStore) {
        throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });
      }

      const scope = await getStoredResourceScope(mastra, requestContext);
      const result = await promptBlockStore.listResolved({
        page,
        perPage,
        orderBy,
        status,
        authorId,
        metadata: scopeStoredResourceMetadata(metadata, scope),
      });

      // For each block, fetch the latest version to compute hasDraft.

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Attach storage: new Mastra({ storage: new MastraLibsql({ url: 'file:./mastra.db' }) }) or another supported adapter
  2. Ensure the database connection env vars are set in the environment running the server
  3. Log mastra.getStorage() at boot to confirm it is non-null before serving requests

Example fix

// before
export const mastra = new Mastra({ agents });
// after
export const mastra = new Mastra({
  agents,
  storage: new MastraLibsql({ url: process.env.LIBSQL_URL ?? 'file:./mastra.db' }),
});
Defensive patterns

Strategy: validation

Validate before calling

if (!mastra.getStorage()) {
  throw new Error('No storage configured; prompt blocks require a storage backend');
}

Try / catch

try {
  const res = await fetch('/api/stored-prompt-blocks?page=0&perPage=10');
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
} catch (e) {
  if (/Storage is not configured/.test(String(e))) {
    // attach storage to the Mastra instance and restart
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/ebc29f2e8bf4edc8. Report an issue: GitHub.