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

  1. Use only `--include` to whitelist specific properties, OR only `--exclude` to blacklist.
  2. 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

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


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/775082f37b969224. Report an issue: GitHub.