{"record":{"id":"37c13c31e25e70a0","repo":"mastra-ai/mastra","slug":"storage-is-not-configured-on-the-mastra-instance","errorCode":null,"errorMessage":"Storage is not configured on the Mastra instance.","messagePattern":"Storage is not configured on the Mastra instance\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mastracode/sdk/src/workflows/service.ts","lineNumber":48,"sourceCode":"  [key: string]: unknown;\n}\n\nexport type WorkflowRunEventCallback = (event: WorkflowRunEvent) => void;\n\ninterface WorkflowRunOutputLike {\n  fullStream: ReadableStream<WorkflowRunEvent>;\n  result: Promise<unknown>;\n}\n\ninterface WorkflowDefinitionsStore {\n  list: (args?: { status?: 'active' | 'archived' }) => Promise<{ definitions: StoredWorkflowRow[]; total: number }>;\n  get: (id: string) => Promise<StoredWorkflowRow | null>;\n  delete: (id: string) => Promise<void>;\n}\n\nasync function workflowDefinitionsStore(mastra: Mastra): Promise<WorkflowDefinitionsStore> {\n  const storage = mastra.getStorage();\n  if (!storage) throw new Error('Storage is not configured on the Mastra instance.');\n  // `getStore` is a generic domain accessor; workflowDefinitions is registered\n  // by mastracode. The domain shape is validated at boot; cast the resolved\n  // store to the interface we exercise.\n  const store = (await (storage as unknown as { getStore: (name: string) => Promise<unknown> }).getStore(\n    'workflowDefinitions',\n  )) as WorkflowDefinitionsStore | undefined;\n  if (!store) throw new Error('workflowDefinitions storage domain is not available.');\n  return store;\n}\n\nexport async function listWorkflows(mastra: Mastra): Promise<{ workflows: StoredWorkflowRow[]; total: number }> {\n  const store = await workflowDefinitionsStore(mastra);\n  const result = await store.list({ status: 'active' });\n  return { workflows: result.definitions, total: result.total };\n}\n\nexport async function getWorkflow(mastra: Mastra, id: string): Promise<StoredWorkflowRow | null> {\n  const store = await workflowDefinitionsStore(mastra);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/sdk/src/workflows/service.ts#L30-L66","documentation":"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.","triggerScenarios":"Constructing `new Mastra({...})` without a `storage` option and then calling listWorkflows / runWorkflow / other service functions in mastracode/sdk/src/workflows/service.ts.","commonSituations":"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.","solutions":["Pass a storage backend when constructing Mastra: `new Mastra({ storage: new LibSQLStore({ url: 'file:./mastra.db' }) })`","Verify the storage config file is actually the one loaded (check mastra/ config wiring)","Guard caller code with a storage existence check and a friendly config error"],"exampleFix":"// before\nexport const mastra = new Mastra({ agents });\n// after\nexport const mastra = new Mastra({ agents, storage: new LibSQLStore({ url: 'file:./mastra.db' }) });","handlingStrategy":"validation","validationCode":"const storage = mastra.getStorage();\nif (!storage) throw new Error('Configure storage before using workflow service: new Mastra({ storage: new LibSQLStore({ url: \"file:./mastra.db\" }) })');","typeGuard":"function hasStorage(m: Mastra): m is Mastra & { getStorage(): NonNullable<ReturnType<Mastra['getStorage']>> } {\n  return m.getStorage() != null;\n}","tryCatchPattern":"try {\n  const { workflows } = await listWorkflows(mastra);\n} catch (e) {\n  if (String(e.message).includes('Storage is not configured')) {\n    console.error('Add a storage backend to your Mastra instance.');\n  } else throw e;\n}","preventionTips":["Always pass `storage` when constructing Mastra if any workflow/feature service is used","Centralize Mastra construction in one factory so storage can't be omitted","Add a boot-time assertion that getStorage() resolves before starting services"],"tags":["configuration","storage","mastra"],"backgroundTag":"missing-config","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}