n8n-io/n8n · error · UserError
No published version found for workflow "${workflows[0].name
Error message
No published version found for workflow "${workflows[0].name}" (${workflows[0].id}) What it means
Thrown by `export:workflow` when `--published` and `--id` are set, the workflow exists, but `getWorkflowsToExport` returns empty — i.e. the workflow's `activeVersionId` has no matching row in WorkflowHistoryRepository (workflow.ts:215-228). The published/active version record is missing.
Source
Thrown at packages/cli/src/commands/export/workflow.ts:135
return;
}
}
}
const workflows = await Container.get(WorkflowRepository).find({
where: this.getWhereFilter(flags),
relations: ['tags', 'shared', 'shared.project'],
});
if (workflows.length === 0) {
throw new UserError('No workflows found with specified filters');
}
const workflowsToExport = await getWorkflowsToExport(workflows, flags);
if (flags.published && workflowsToExport.length === 0) {
if (flags.id)
throw new UserError(
`No published version found for workflow "${workflows[0].name}" (${workflows[0].id})`,
);
else throw new UserError('No workflows with published versions found.');
}
if (flags.version && flags.id && workflowsToExport.length === 0) {
throw new UserError(
`Version "${flags.version}" not found for workflow "${workflows[0].name}" (${workflows[0].id})`,
);
}
if (workflowsToExport.length === 0) {
throw new UserError('No workflows found with specified filters');
}
if (flags.separate) {
let fileContents: string;
let i: number;
for (i = 0; i < workflowsToExport.length; i++) {
fileContents = JSON.stringify(workflowsToExport[i], null, flags.pretty ? 2 : undefined);View on GitHub (pinned to 5ac6606e81)
Solutions
- Drop `--published` to export the current working version instead of the published one.
- Activate/publish the workflow in the UI first so an activeVersionId is set and history is recorded.
- Check `SELECT active_version_id FROM workflow_entity WHERE id=X` — if NULL, the workflow has no published version.
- If history rows are missing, re-run with `--version=<some-version-id>` for a version that exists, or omit version flags entirely.
Example fix
// before n8n export:workflow --id=X --published // after — export current version instead n8n export:workflow --id=X
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the workflow has a published (active) version before exporting
async function hasPublishedVersion(ds: DataSource, id: string): Promise<boolean> {
const row = await ds.getRepository('workflow_entity').findOne({ where: { id }, select: ['activeVersionId'] });
return Boolean(row?.activeVersionId);
}
if (!(await hasPublishedVersion(ds, id))) {
console.error('No published version — falling back to current version');
flags.published = false;
} Try / catch
try {
await execN8n(['export:workflow', '--id', id, '--published']);
} catch (e) {
if (e.message.startsWith('No published version')) {
// fall back to current version
await execN8n(['export:workflow', '--id', id]);
} else throw e;
} Prevention
- Activate workflows in the UI before exporting their published version.
- Verify activeVersionId is set in the workflow_entity row before scripting --published exports.
- Keep workflow history enabled so versions are recorded.
When it happens
Trigger: `n8n export:workflow --id=X --published` on a workflow that was never activated, was deactivated, or whose workflow_history rows were pruned/migrated away. `getTargetVersionId` returns `workflow.activeVersionId ?? null`; if null or absent from history, the workflow is filtered out at mergeHistoriesIntoWorkflows (workflow.ts:259).
Common situations: Exporting a draft workflow that has never been published; workflow history feature disabled or history table cleaned; upgrading from an n8n version that did not track activeVersionId; running against a workflow imported without its history.
Related errors
- No workflows with published versions found.
- Version "${flags.version}" not found for workflow "${workflo
- No workflows found with specified filters
- No credentials found with specified filters
- Filesystem error while creating the output directory: ${e in
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/02eeeaccc2feb7dc.
Report an issue: GitHub.