mastra-ai/mastra · error
No workflow with id "${id}".
Error message
No workflow with id "${id}". What it means
get-workflow loads a workflow definition by id and throws this error when the storage lookup returns undefined/null. It means no workflow with the given id exists (or it is not visible to the current storage backend).
Source
Thrown at mastracode/sdk/src/tools/workflows/get-workflow.ts:26
export const getWorkflowTool = createTool({
id: 'get-workflow',
description: 'Return the full stored definition of a workflow (input/output schemas + the step graph).',
inputSchema: z.object({
id: z.string().describe('The workflow id.'),
}),
outputSchema: z.object({
id: z.string(),
description: z.string().optional(),
status: z.enum(['active', 'archived']),
inputSchema: z.any().optional(),
outputSchema: z.any().optional(),
graph: z.array(z.any()).optional(),
}),
execute: async ({ id }, { mastra }) => {
if (!mastra) throw new Error('get-workflow requires a Mastra context.');
const def = await getWorkflow(mastra as Mastra, id);
if (!def) throw new Error(`No workflow with id "${id}".`);
return {
id: def.id,
description: def.description,
status: def.status,
inputSchema: def.inputSchema,
outputSchema: def.outputSchema,
graph: def.graph,
};
},
});
View on GitHub (pinned to 75dd419e61)
Solutions
- Verify the id is correct — list workflows or check the id returned by save-workflow.
- Confirm you're pointed at the same storage backend where the workflow was saved.
- Re-create the workflow if it was deleted, or check whether it was archived.
Example fix
// before
await getWorkflowTool.execute({ id: 'my-workflow' }, { mastra });
// after: confirm id first
const wf = await mastra.getStorage().listWorkflows?.();
await getWorkflowTool.execute({ id: wf.find(w => w.id.includes('my-workflow'))?.id }, { mastra }); Defensive patterns
Strategy: try-catch
Validate before calling
const exists = await listWorkflowIds(mastra); // ensure id present before lookup
if (!exists.includes(id)) console.warn(`workflow "${id}" not found — get-workflow will throw`); Type guard
function isWorkflowDef(d: unknown): d is { id: string; description?: string; status: 'active' | 'archived' } { return !!d && typeof d === 'object' && typeof (d as any).id === 'string'; } Try / catch
try { const def = await tool.execute({ id }, { mastra }); } catch (e) { if (e.message.startsWith('No workflow with id')) { /* fall back to listing workflows or recreating it */ } else throw e; } Prevention
- Store and pass ids returned by save-workflow rather than hand-typing them.
- Confirm storage backend/env consistency (dev vs prod).
- Check archived/deleted status before lookup.
When it happens
Trigger: Calling get-workflow with an id that was never saved, was deleted via delete-workflow, or belongs to a different storage backend/environment.
Common situations: Typo in the workflow id; using a dev storage in prod (or vice versa); workflow previously archived/deleted; save from create-workflow actually failed earlier.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Version-control repository not found.
- Project repository not found for this organization.
- Source-control connection not found for this organization.
- Repository not found for this organization.
- Source-control installation not found for this organization.
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/687c72541d144de0.
Report an issue: GitHub.