n8n-io/n8n · error · UserError
You cannot use `--include` and `--exclude` together. Use one
Error message
You cannot use `--include` and `--exclude` together. Use one or the other.
What it means
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.
Source
Thrown at packages/cli/src/commands/import/credentials.ts:111
}
if (flags.separate) {
if (fs.existsSync(flags.input)) {
if (!fs.lstatSync(flags.input).isDirectory()) {
this.logger.info('The argument to --input must be a directory');
return;
}
}
}
if (flags.projectId && flags.userId) {
throw new UserError(
'You cannot use `--userId` and `--projectId` together. Use one or the other.',
);
}
if (flags.include && flags.exclude) {
throw new UserError(
'You cannot use `--include` and `--exclude` together. Use one or the other.',
);
}
const include = this.parseCredentialProperties(flags.include, '--include');
const exclude = this.parseCredentialProperties(flags.exclude, '--exclude');
const credentials = await this.readCredentials({
inputPath: flags.input,
separate: flags.separate,
include,
exclude,
});
await Container.get(DbLockService).withLock(
DbLock.INSTANCE_AI_SETTINGS,
async (transactionManager, ctx) => {
const project = await this.getProject(transactionManager, flags.userId, flags.projectId);View on GitHub (pinned to 5ac6606e81)
Solutions
- Use only `--include` to whitelist specific properties, OR only `--exclude` to blacklist.
- If you need both behaviours, run two separate imports.
Example fix
// before n8n import:credentials --input=f.json --include=id,name --exclude=createdAt // after n8n import:credentials --input=f.json --include=id,name
Defensive patterns
Strategy: validation
Validate before calling
function validatePropertyFlags(flags: { include?: string; exclude?: string }) {
if (flags.include && flags.exclude) {
throw new Error('Pass exactly one of --include or --exclude, not both.');
}
}
validatePropertyFlags(flags); Prevention
- Treat --include and --exclude as alternatives, not composable filters.
- Standardise team scripts on --include only.
When it happens
Trigger: `n8n import:credentials --input=f.json --include=id,name --exclude=createdAt`.
Common situations: Building up a command incrementally and forgetting prior flags; misunderstanding filter semantics.
Related errors
- You cannot use `--userId` and `--projectId` together. Use on
- Provider connections cannot be global, managed, or dynamical
- ${flagName} must contain at least one property name.
- No importable properties found. Please check the --include f
- You cannot use `--userId` and `--projectId` together. Use on
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/775082f37b969224.
Report an issue: GitHub.