{"record":{"id":"5e7e25c79b826660","repo":"n8n-io/n8n","slug":"the-file-flag-is-no-longer-supported-please-fir","errorCode":null,"errorMessage":"The --file flag is no longer supported. Please first import the workflow and then execute it using the --id flag.","messagePattern":"The --file flag is no longer supported\\. Please first import the workflow and then execute it using the --id flag\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/execute.ts","lineNumber":53,"sourceCode":"\tasync init() {\n\t\tawait super.init();\n\t\tawait this.initLicense();\n\t\tawait this.initCommunityPackages();\n\t\tawait this.initBinaryDataService();\n\t\tawait this.initDataDeduplicationService();\n\t\tawait this.initExternalHooks();\n\t}\n\n\tasync run() {\n\t\tconst { flags } = this;\n\n\t\tif (!flags.id) {\n\t\t\tthis.logger.info('\"--id\" has to be set!');\n\t\t\treturn;\n\t\t}\n\n\t\tif (flags.file) {\n\t\t\tthrow new UserError(\n\t\t\t\t'The --file flag is no longer supported. Please first import the workflow and then execute it using the --id flag.',\n\t\t\t\t{ level: 'warning' },\n\t\t\t);\n\t\t}\n\n\t\tlet workflowId: string | undefined;\n\t\tlet workflowData: IWorkflowBase | null = null;\n\n\t\tif (flags.id) {\n\t\t\t// Id of workflow is given\n\t\t\tworkflowId = flags.id;\n\t\t\tworkflowData = await Container.get(WorkflowRepository).findOneBy({ id: workflowId });\n\t\t\tif (workflowData === null) {\n\t\t\t\tthis.logger.info(`The workflow with the id \"${workflowId}\" does not exist.`);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/execute.ts#L35-L71","documentation":"The `n8n execute` command throws UserError when --file is passed. The --file flag was removed; workflows must now be imported first and executed via --id. Message includes the migration instruction. The check fires only after --id is verified present.","triggerScenarios":"Invoking `n8n execute --file=workflow.json` (with or without --id). The legacy flag is hard-rejected.","commonSituations":"Script or docs referencing the old --file execution mode after upgrading n8n; muscle-memory CLI invocation from pre-migration workflows.","solutions":["Import the workflow first: `n8n import:workflow --input=workflow.json`, then `n8n execute --id=<id>`.","Update any scripts/docs that still reference --file to the import+execute flow."],"exampleFix":"# before\nn8n execute --file=workflow.json\n\n# after\nn8n import:workflow --input=workflow.json\nn8n execute --id=<imported-workflow-id>","handlingStrategy":"validation","validationCode":"// Before invoking, strip legacy flags\nconst flags = { ...rawFlags };\nif ('file' in flags) { /* redirect to import:workflow + execute --id */ }\ndelete flags.file;","typeGuard":"function isRemovedFlagError(error: unknown): boolean {\n  return error instanceof Error && error.message.includes('--file flag is no longer supported');\n}","tryCatchPattern":"try {\n  await Execute.run(argv);\n} catch (e) {\n  if (isRemovedFlagError(e)) { /* run import:workflow then execute --id */ }\n  else throw e;\n}","preventionTips":["Update all scripts/docs to the import-then-execute flow.","Always pass --id when automating executions.","Track n8n release notes for CLI flag removals."],"tags":["cli","execute","breaking-change","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}