{"record":{"id":"0bda5390ae4f5fe4","repo":"n8n-io/n8n","slug":"you-cannot-use-userid-and-projectid-togeth","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/credentials.ts","lineNumber":105,"sourceCode":"\tasync run(): Promise<void> {\n\t\tconst { flags } = this;\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\tif (flags.include && flags.exclude) {\n\t\t\tthrow new UserError(\n\t\t\t\t'You cannot use `--include` and `--exclude` together. Use one or the other.',\n\t\t\t);\n\t\t}\n\n\t\tconst include = this.parseCredentialProperties(flags.include, '--include');\n\t\tconst exclude = this.parseCredentialProperties(flags.exclude, '--exclude');\n\n\t\tconst credentials = await this.readCredentials({\n\t\t\tinputPath: flags.input,\n\t\t\tseparate: flags.separate,\n\t\t\tinclude,\n\t\t\texclude,","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/import/credentials.ts#L87-L123","documentation":"Thrown by `import:credentials` when both `--userId` and `--projectId` are passed. They are mutually exclusive because each credential must be assigned to exactly one owning project — either the user's personal project (via --userId) or an explicit project (--projectId).","triggerScenarios":"`n8n import:credentials --input=f.json --userId=A --projectId=B`. The check at credentials.ts:104 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: use `--userId` for the user's personal project, or `--projectId` for a specific project.","Omit both to fall back to the global owner's personal project."],"exampleFix":"// before\nn8n import:credentials --input=f.json --userId=A --projectId=B\n// after\nn8n import:credentials --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":["Build import commands from a single source of truth (e.g. CI variable for the target).","Document that --userId resolves to the user's personal project, so --projectId is redundant with it."],"tags":["cli","import","credentials","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"}