{"record":{"id":"775082f37b969224","repo":"n8n-io/n8n","slug":"you-cannot-use-include-and-exclude-togethe","errorCode":null,"errorMessage":"You cannot use `--include` and `--exclude` together. Use one or the other.","messagePattern":"You cannot use `--include` and `--exclude` together\\. Use one or the other\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/import/credentials.ts","lineNumber":111,"sourceCode":"\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,\n\t\t});\n\n\t\tawait Container.get(DbLockService).withLock(\n\t\t\tDbLock.INSTANCE_AI_SETTINGS,\n\t\t\tasync (transactionManager, ctx) => {\n\t\t\t\tconst project = await this.getProject(transactionManager, flags.userId, flags.projectId);","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/import/credentials.ts#L93-L129","documentation":"Thrown by `import:credentials` when both `--include` and `--exclude` are passed. They are mutually exclusive property filters — include is a whitelist, exclude is a blacklist, and combining them is ambiguous.","triggerScenarios":"`n8n import:credentials --input=f.json --include=id,name --exclude=createdAt`.","commonSituations":"Building up a command incrementally and forgetting prior flags; misunderstanding filter semantics.","solutions":["Use only `--include` to whitelist specific properties, OR only `--exclude` to blacklist.","If you need both behaviours, run two separate imports."],"exampleFix":"// before\nn8n import:credentials --input=f.json --include=id,name --exclude=createdAt\n// after\nn8n import:credentials --input=f.json --include=id,name","handlingStrategy":"validation","validationCode":"function validatePropertyFlags(flags: { include?: string; exclude?: string }) {\n  if (flags.include && flags.exclude) {\n    throw new Error('Pass exactly one of --include or --exclude, not both.');\n  }\n}\nvalidatePropertyFlags(flags);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --include and --exclude as alternatives, not composable filters.","Standardise team scripts on --include only."],"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-13T09:17:06.757Z"}