{"record":{"id":"263de5029e9cf33f","repo":"n8n-io/n8n","slug":"no-workflows-with-published-versions-found","errorCode":null,"errorMessage":"No workflows with published versions found.","messagePattern":"No workflows with published versions found\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/export/workflow.ts","lineNumber":138,"sourceCode":"\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');\n\t\t}\n\n\t\tif (flags.separate) {\n\t\t\tlet fileContents: string;\n\t\t\tlet i: number;\n\t\t\tfor (i = 0; i < workflowsToExport.length; i++) {\n\t\t\t\tfileContents = JSON.stringify(workflowsToExport[i], null, flags.pretty ? 2 : undefined);\n\t\t\t\tconst filename = `${\n\t\t\t\t\t(flags.output!.endsWith(path.sep) ? flags.output : flags.output + path.sep) +\n\t\t\t\t\tworkflowsToExport[i].id","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/export/workflow.ts#L120-L156","documentation":"Thrown by `export:workflow` when `--published` is set without `--id` (i.e. with `--all` or `--projectId`), workflows were found, but none of them have a published version resolvable through WorkflowHistoryRepository. The aggregate counterpart of error 1301.","triggerScenarios":"`n8n export:workflow --all --published` or `--projectId=X --published` where every matched workflow has a null activeVersionId, has never been activated, or whose history rows are absent.","commonSituations":"Bulk export on a dev instance where workflows were created via CLI/import but never activated through the UI; history pruning removed all version rows; environments where workflow activation is disabled.","solutions":["Drop `--published` to export current draft versions of all workflows.","Activate workflows in the UI before exporting their published versions.","Audit: `SELECT count(*) FILTER (WHERE active_version_id IS NULL) FROM workflow_entity;` to see how many lack published versions."],"exampleFix":"// before\nn8n export:workflow --all --published --output=backups/\n// after\nn8n export:workflow --all --output=backups/","handlingStrategy":"validation","validationCode":"// Count workflows with a non-null activeVersionId before bulk --published export\nasync function publishedCount(ds: DataSource): Promise<number> {\n  const { count } = await ds.getRepository('workflow_entity')\n    .createQueryBuilder('w').where('w.activeVersionId IS NOT NULL').getCount();\n  return count;\n}\nif (await publishedCount(ds) === 0) {\n  console.error('No published workflows — dropping --published flag');\n  flags.published = false;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await execN8n(['export:workflow', '--all', '--published', '--output', dir]);\n} catch (e) {\n  if (e.message.includes('No workflows with published versions')) {\n    await execN8n(['export:workflow', '--all', '--output', dir]);\n  } else throw e;\n}","preventionTips":["Before bulk --published export, count workflows with non-null activeVersionId.","Don't rely on --published for dev instances where workflows are rarely activated."],"tags":["cli","export","workflow","published","bulk","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}