mastra-ai/mastra · error · HTTPException

Storage is not configured

Error message

Storage is not configured

What it means

The dynamic-workflows list route requires a storage adapter on the Mastra instance. mastra.getStorage() returns undefined when no storage was configured, so the handler throws an HTTPException 500 'Storage is not configured'. Dynamic workflow definitions are persisted in storage, so the endpoint cannot function without it.

Source

Thrown at packages/server/src/server/handlers/dynamic-workflows.ts:37

 *
 * Mirrors `LIST_STORED_AGENTS_ROUTE` but without favorites/visibility/authorship
 * scoping (which the workflow-definitions domain doesn't carry in v1).
 */
export const LIST_DYNAMIC_WORKFLOWS_ROUTE = createRoute({
  method: 'GET',
  path: '/stored/workflows',
  responseType: 'json',
  queryParamSchema: listDynamicWorkflowsQuerySchema,
  responseSchema: listDynamicWorkflowsResponseSchema,
  summary: 'List dynamic workflow definitions',
  description: 'Returns workflow definitions persisted to storage. Filterable by status and authorId.',
  tags: ['Dynamic Workflows'],
  requiresAuth: true,
  requiresPermission: 'stored-workflows:read',
  handler: async ({ mastra, status, authorId }) => {
    try {
      const storage = mastra.getStorage();
      if (!storage) throw new HTTPException(500, { message: 'Storage is not configured' });

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

      const result = await store.list({ status: status ?? 'active', authorId });
      return { workflows: result.definitions, total: result.total };
    } catch (error) {
      return handleError(error, 'Error listing dynamic workflows');
    }
  },
});

/**
 * GET /stored/workflows/:dynamicWorkflowId — get one dynamic workflow.
 */
export const GET_DYNAMIC_WORKFLOW_ROUTE = createRoute({
  method: 'GET',
  path: '/stored/workflows/:dynamicWorkflowId',

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Configure storage on the Mastra instance: pass `storage: new MastraStorage(...)` (LibSQL/Postgres/Upstash etc.) in the constructor
  2. Verify storage-related env vars are set in the deployment environment
  3. If storage is intentionally absent, do not call the dynamic-workflows routes
  4. Add a startup check that warns when getStorage() is undefined but workflow routes are served

Example fix

// before
export const mastra = new Mastra({ agents, workflows });
// after
export const mastra = new Mastra({
  agents,
  workflows,
  storage: new LibSQLStore({ url: process.env.DATABASE_URL! }),
});
Defensive patterns

Strategy: validation

Validate before calling

const storage = mastra.getStorage();
if (!storage) throw new Error('Configure storage on the Mastra instance before using dynamic workflows');

Type guard

function hasStorage(mastra: Mastra): boolean {
  return typeof mastra.getStorage === 'function' && mastra.getStorage() != null;
}

Try / catch

try {
  const res = await fetch('/api/dynamic-workflows');
  if (res.status === 500) throw new Error('Server storage not configured — set storage on Mastra instance');
  return res.json();
} catch (err) {
  logger.error({ err }, 'list dynamic workflows failed');
}

Prevention

When it happens

Trigger: GET /api/dynamic-workflows (list stored workflows) against a Mastra instance constructed without a storage option (e.g. `new Mastra({...})` with no `storage:` key, or storage removed during refactor).

Common situations: Local/dev Mastra instances with no database configured, deployments where storage env vars (e.g. DATABASE_URL / Upstash / LibSQL URL) are missing so storage is skipped, or examples migrated to the new Mastra constructor forgetting the storage field.

Related errors


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