n8n-io/n8n · error · UserError

You cannot use `--userId` and `--projectId` together. Use on

Error message

You cannot use `--userId` and `--projectId` together. Use one or the other.

What it means

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).

Source

Thrown at packages/cli/src/commands/import/workflow.ts:128

			);
		}

		if (!flags.input) {
			this.logger.info('An input file or directory with --input must be provided');
			return;
		}

		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.',
			);
		}

		const project = await this.getProject(flags.userId, flags.projectId);

		const ownerUser = await Container.get(UserRepository).findOneByOrFail({
			role: { slug: GLOBAL_OWNER_ROLE.slug },
		});
		// This userId will be used as the actor for publish/unpublish workflow actions
		const userId = flags.userId ?? ownerUser.id;

		const workflows = await this.readWorkflows(flags.input, flags.separate);

		const result = await this.checkRelations(workflows, flags.projectId, flags.userId);

		if (!result.success) {
			throw new UserError(result.message);

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Pick one: `--userId` for personal project, or `--projectId` for a specific project.
  2. Omit both to fall back to the global owner's personal project.

Example fix

// before
n8n import:workflow --input=f.json --userId=A --projectId=B
// after
n8n import:workflow --input=f.json --projectId=B
Defensive patterns

Strategy: validation

Validate before calling

function validateImportFlags(flags: { userId?: string; projectId?: string }) {
  if (flags.userId && flags.projectId) {
    throw new Error('Pass exactly one of --userId or --projectId, not both.');
  }
}
validateImportFlags(flags);

Prevention

When it happens

Trigger: `n8n import:workflow --input=f.json --userId=A --projectId=B`. The check at workflow.ts:127 fires before any DB work.

Common situations: Copy-pasting a command and forgetting to remove one flag; misunderstanding that --userId implies the user's personal project.

Related errors


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