{"record":{"id":"fce426877c734812","repo":"n8n-io/n8n","slug":"you-cannot-use-userid-and-projectid-togeth-fce426","errorCode":null,"errorMessage":"You cannot use `--userId` and `--projectId` together. Use one or the other.","messagePattern":"You cannot use `--userId` and `--projectId` together\\. Use one or the other\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/import/workflow.ts","lineNumber":128,"sourceCode":"\t\t\t);\n\t\t}\n\n\t\tif (!flags.input) {\n\t\t\tthis.logger.info('An input file or directory with --input must be provided');\n\t\t\treturn;\n\t\t}\n\n\t\tif (flags.separate) {\n\t\t\tif (fs.existsSync(flags.input)) {\n\t\t\t\tif (!fs.lstatSync(flags.input).isDirectory()) {\n\t\t\t\t\tthis.logger.info('The argument to --input must be a directory');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (flags.projectId && flags.userId) {\n\t\t\tthrow new UserError(\n\t\t\t\t'You cannot use `--userId` and `--projectId` together. Use one or the other.',\n\t\t\t);\n\t\t}\n\n\t\tconst project = await this.getProject(flags.userId, flags.projectId);\n\n\t\tconst ownerUser = await Container.get(UserRepository).findOneByOrFail({\n\t\t\trole: { slug: GLOBAL_OWNER_ROLE.slug },\n\t\t});\n\t\t// This userId will be used as the actor for publish/unpublish workflow actions\n\t\tconst userId = flags.userId ?? ownerUser.id;\n\n\t\tconst workflows = await this.readWorkflows(flags.input, flags.separate);\n\n\t\tconst result = await this.checkRelations(workflows, flags.projectId, flags.userId);\n\n\t\tif (!result.success) {\n\t\t\tthrow new UserError(result.message);","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/import/workflow.ts#L110-L146","documentation":"Thrown by `import:workflow` when both --userId and --projectId are passed. Same mutual-exclusivity rule as error 1305 but for workflow import — a workflow is assigned to exactly one owning project, either the user's personal project (--userId) or an explicit project (--projectId).","triggerScenarios":"`n8n import:workflow --input=f.json --userId=A --projectId=B`. The check at workflow.ts:127 fires before any DB work.","commonSituations":"Copy-pasting a command and forgetting to remove one flag; misunderstanding that --userId implies the user's personal project.","solutions":["Pick one: `--userId` for personal project, or `--projectId` for a specific project.","Omit both to fall back to the global owner's personal project."],"exampleFix":"// before\nn8n import:workflow --input=f.json --userId=A --projectId=B\n// after\nn8n import:workflow --input=f.json --projectId=B","handlingStrategy":"validation","validationCode":"function validateImportFlags(flags: { userId?: string; projectId?: string }) {\n  if (flags.userId && flags.projectId) {\n    throw new Error('Pass exactly one of --userId or --projectId, not both.');\n  }\n}\nvalidateImportFlags(flags);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass exactly one ownership flag, or neither to fall back to the global owner.","Use --projectId in CI for reproducibility."],"tags":["cli","import","workflow","flags","mutually-exclusive","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}