mastra-ai/mastra · error

Storage is not configured on the Mastra instance.

Error message

Storage is not configured on the Mastra instance.

What it means

workflowDefinitionsStore resolves the storage layer from the Mastra instance before any workflow CRUD. If mastra.getStorage() returns nothing, no storage backend was configured on the instance, so workflow definitions cannot be listed, stored, or deleted and the service refuses to proceed.

Source

Thrown at mastracode/sdk/src/workflows/service.ts:48

  [key: string]: unknown;
}

export type WorkflowRunEventCallback = (event: WorkflowRunEvent) => void;

interface WorkflowRunOutputLike {
  fullStream: ReadableStream<WorkflowRunEvent>;
  result: Promise<unknown>;
}

interface WorkflowDefinitionsStore {
  list: (args?: { status?: 'active' | 'archived' }) => Promise<{ definitions: StoredWorkflowRow[]; total: number }>;
  get: (id: string) => Promise<StoredWorkflowRow | null>;
  delete: (id: string) => Promise<void>;
}

async function workflowDefinitionsStore(mastra: Mastra): Promise<WorkflowDefinitionsStore> {
  const storage = mastra.getStorage();
  if (!storage) throw new Error('Storage is not configured on the Mastra instance.');
  // `getStore` is a generic domain accessor; workflowDefinitions is registered
  // by mastracode. The domain shape is validated at boot; cast the resolved
  // store to the interface we exercise.
  const store = (await (storage as unknown as { getStore: (name: string) => Promise<unknown> }).getStore(
    'workflowDefinitions',
  )) as WorkflowDefinitionsStore | undefined;
  if (!store) throw new Error('workflowDefinitions storage domain is not available.');
  return store;
}

export async function listWorkflows(mastra: Mastra): Promise<{ workflows: StoredWorkflowRow[]; total: number }> {
  const store = await workflowDefinitionsStore(mastra);
  const result = await store.list({ status: 'active' });
  return { workflows: result.definitions, total: result.total };
}

export async function getWorkflow(mastra: Mastra, id: string): Promise<StoredWorkflowRow | null> {
  const store = await workflowDefinitionsStore(mastra);

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Pass a storage backend when constructing Mastra: `new Mastra({ storage: new LibSQLStore({ url: 'file:./mastra.db' }) })`
  2. Verify the storage config file is actually the one loaded (check mastra/ config wiring)
  3. Guard caller code with a storage existence check and a friendly config error

Example fix

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

Strategy: validation

Validate before calling

const storage = mastra.getStorage();
if (!storage) throw new Error('Configure storage before using workflow service: new Mastra({ storage: new LibSQLStore({ url: "file:./mastra.db" }) })');

Type guard

function hasStorage(m: Mastra): m is Mastra & { getStorage(): NonNullable<ReturnType<Mastra['getStorage']>> } {
  return m.getStorage() != null;
}

Try / catch

try {
  const { workflows } = await listWorkflows(mastra);
} catch (e) {
  if (String(e.message).includes('Storage is not configured')) {
    console.error('Add a storage backend to your Mastra instance.');
  } else throw e;
}

Prevention

When it happens

Trigger: Constructing `new Mastra({...})` without a `storage` option and then calling listWorkflows / runWorkflow / other service functions in mastracode/sdk/src/workflows/service.ts.

Common situations: Copy-pasted Mastra init without storage config; agents-only setup where storage was deemed unnecessary; storage added later in a feature branch but the service called from an entry point that builds Mastra without it.

Related errors


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