{"record":{"id":"d8c83d5a892006ef","repo":"n8n-io/n8n","slug":"no-workflows-found-with-specified-filters","errorCode":null,"errorMessage":"No workflows found with specified filters","messagePattern":"No workflows found with specified filters","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/export/workflow.ts","lineNumber":128,"sourceCode":"\t\t\t\t\t`Filesystem error while creating the output directory: ${e instanceof Error ? e.message : String(e)}`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (flags.output) {\n\t\t\tif (fs.existsSync(flags.output)) {\n\t\t\t\tif (fs.lstatSync(flags.output).isDirectory()) {\n\t\t\t\t\tthis.logger.info('The parameter --output must be a writeable file');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst workflows = await Container.get(WorkflowRepository).find({\n\t\t\twhere: this.getWhereFilter(flags),\n\t\t\trelations: ['tags', 'shared', 'shared.project'],\n\t\t});\n\n\t\tif (workflows.length === 0) {\n\t\t\tthrow new UserError('No workflows found with specified filters');\n\t\t}\n\n\t\tconst workflowsToExport = await getWorkflowsToExport(workflows, flags);\n\n\t\tif (flags.published && workflowsToExport.length === 0) {\n\t\t\tif (flags.id)\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t`No published version found for workflow \"${workflows[0].name}\" (${workflows[0].id})`,\n\t\t\t\t);\n\t\t\telse throw new UserError('No workflows with published versions found.');\n\t\t}\n\t\tif (flags.version && flags.id && workflowsToExport.length === 0) {\n\t\t\tthrow new UserError(\n\t\t\t\t`Version \"${flags.version}\" not found for workflow \"${workflows[0].name}\" (${workflows[0].id})`,\n\t\t\t);\n\t\t}\n\t\tif (workflowsToExport.length === 0) {\n\t\t\tthrow new UserError('No workflows found with specified filters');","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/export/workflow.ts#L110-L146","documentation":"Thrown by the `export:workflow` CLI command when the WorkflowRepository lookup with the supplied filters returns zero rows. The filters come from `--id`, `--projectId`, or `--all` (the selector logic in getWhereFilter). It is a UserError, meaning the user-supplied input — not the system — is at fault.","triggerScenarios":"Running `n8n export:workflow --id=<non-existent-id>`, `--projectId=<project-with-no-workflows>`, or `--all` against a fresh/empty n8n database. The check at workflow.ts:127 fires before any version resolution, so even workflows missing history still count as found at this stage.","commonSituations":"Wrong workflow ID copied from a different environment; targeting a projectId whose workflows were deleted; running export against a newly initialised SQLite DB before any workflows exist; mistyping the ID.","solutions":["List workflows first with `n8n list:workflow` (or query the DB) to confirm the ID/projectId exists in this environment.","Drop the `--id`/`--projectId` filter and use `--all` to confirm the DB has any workflows at all.","Verify you are pointed at the correct n8n database (check N8N_DEFAULT_BINARY_DATA_MODE / DB env vars)."],"exampleFix":"// before\nn8n export:workflow --id=abc123 --output=out.json\n// after — verify the ID exists first\nn8n list:workflow\nn8n export:workflow --id=<id-from-list> --output=out.json","handlingStrategy":"validation","validationCode":"import { DataSource } from '@n8n/db';\n// Before export, confirm the workflow exists\nasync function workflowExists(ds: DataSource, id: string): Promise<boolean> {\n  return await ds.getRepository('workflow_entity').exist({ where: { id } });\n}\nif (!(await workflowExists(ds, flags.id))) {\n  console.error('Workflow not found — skipping export');\n  process.exit(0);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await execN8n(['export:workflow', '--id', id, '--output', out]);\n} catch (e) {\n  if (e.message.includes('No workflows found')) {\n    // expected when source env is empty — skip gracefully\n  } else throw e;\n}","preventionTips":["Always run `n8n list:workflow` before scripting an export to confirm IDs exist.","Script exports defensively: skip-and-continue when this error appears in batch jobs.","Pin the same DB / environment when copying IDs between operations."],"tags":["cli","export","workflow","filter","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}