{"record":{"id":"cc2ca8289cabbdb0","repo":"n8n-io/n8n","slug":"you-must-use-exactly-one-of-userid-project","errorCode":null,"errorMessage":"You must use exactly one of `--userId`, `--projectId` or `--deleteWorkflowsAndCredentials`.","messagePattern":"You must use exactly one of `--userId`, `--projectId` or `--deleteWorkflowsAndCredentials`\\.","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/ldap/reset.ts","lineNumber":70,"sourceCode":"\tdescription:\n\t\t'Resets the database to the default ldap state.\\n\\nTHIS DELETES ALL LDAP MANAGED USERS.',\n\texamples: [\n\t\t'--userId=1d64c3d2-85fe-4a83-a649-e446b07b3aae',\n\t\t'--projectId=Ox8O54VQrmBrb4qL',\n\t\t'--deleteWorkflowsAndCredentials',\n\t],\n\tflagsSchema,\n})\nexport class Reset extends BaseCommand<z.infer<typeof flagsSchema>> {\n\tasync run(): Promise<void> {\n\t\tconst { flags } = this;\n\t\tconst numberOfOptions =\n\t\t\tNumber(!!flags.userId) +\n\t\t\tNumber(!!flags.projectId) +\n\t\t\tNumber(!!flags.deleteWorkflowsAndCredentials);\n\n\t\tif (numberOfOptions !== 1) {\n\t\t\tthrow new UserError(wrongFlagsError);\n\t\t}\n\n\t\tconst owner = await this.getOwner();\n\t\tconst ldapIdentities = await Container.get(AuthIdentityRepository).find({\n\t\t\twhere: { providerType: 'ldap' },\n\t\t\tselect: ['userId'],\n\t\t});\n\t\tconst personalProjectIds = await Container.get(\n\t\t\tProjectRelationRepository,\n\t\t).getPersonalProjectsForUsers(ldapIdentities.map((i) => i.userId));\n\n\t\t// Migrate all workflows and credentials to another project.\n\t\tif (flags.projectId ?? flags.userId) {\n\t\t\tif (flags.userId && ldapIdentities.some((i) => i.userId === flags.userId)) {\n\t\t\t\tthrow new UserError(\n\t\t\t\t\t`Can't migrate workflows and credentials to the user with the ID ${flags.userId}. That user was created via LDAP and will be deleted as well.`,\n\t\t\t\t);\n\t\t\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/commands/ldap/reset.ts#L52-L88","documentation":"Thrown by the `ldap:reset` CLI command when the number of mutually-exclusive migration flags is not exactly one. The command requires precisely one of `--userId`, `--projectId`, or `--deleteWorkflowsAndCredentials` because each implies a different post-LDAP-reset cleanup strategy (reassign to a user, reassign to a project, or hard-delete). It is a UserError, meaning the operator's invocation caused it, not a system fault.","triggerScenarios":"Running `n8n ldap:reset` with zero flags, with two or three flags together (e.g. `--userId=X --projectId=Y`), or relying on a default that does not exist. The check sums `Number(!!flags.userId) + Number(!!flags.projectId) + Number(!!flags.deleteWorkflowsAndCredentials)` and compares to 1.","commonSituations":"Operators running the LDAP reset without reading the help text; copy-pasting a command template that already contained two flags; scripting the reset and forgetting to pass a flag in one code path.","solutions":["Run `n8n ldap:reset --help` and pick exactly one of the three flags.","If you want to keep the orphaned workflows/credentials, choose `--userId` or `--projectId` pointing at a non-LDAP target; otherwise use `--deleteWorkflowsAndCredentials`.","Audit any wrapper script to ensure it always passes exactly one flag and fails loudly otherwise."],"exampleFix":"// before\nn8n ldap:reset --userId=ABC --projectId=XYZ\n// after\nn8n ldap:reset --projectId=XYZ","handlingStrategy":"validation","validationCode":"const flags = { userId, projectId, deleteWorkflowsAndCredentials };\nconst count = Number(!!flags.userId) + Number(!!flags.projectId) + Number(!!flags.deleteWorkflowsAndCredentials);\nif (count !== 1) {\n  throw new Error('Pass exactly one of --userId, --projectId, or --deleteWorkflowsAndCredentials');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap `ldap:reset` invocations in a script that validates flags before exec'ing.","Print `n8n ldap:reset --help` once and pin the exact flag combination your runbook uses."],"tags":["cli","ldap","flag-validation","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}