{"record":{"id":"3aafa44969d738ec","repo":"n8n-io/n8n","slug":"request-to-delete-a-user-failed-because-the-user-t-3aafa4","errorCode":null,"errorMessage":"Request to delete a user failed because the user to delete and the transferee are the same user","messagePattern":"Request to delete a user failed because the user to delete and the transferee are the same user","errorType":"exception","errorClass":"BadRequestError","httpStatus":400,"severity":"error","filePath":"packages/cli/src/controllers/users.controller.ts","lineNumber":257,"sourceCode":"\t\t\trelations: ['role'],\n\t\t});\n\n\t\tif (!userToDelete) {\n\t\t\tthrow new NotFoundError(\n\t\t\t\t'Request to delete a user failed because the user to delete was not found in DB',\n\t\t\t);\n\t\t}\n\n\t\tif (userToDelete.role.slug === GLOBAL_OWNER_ROLE.slug) {\n\t\t\tthrow new ForbiddenError('Instance owner cannot be deleted.');\n\t\t}\n\n\t\tconst personalProjectToDelete = await this.projectRepository.getPersonalProjectForUserOrFail(\n\t\t\tuserToDelete.id,\n\t\t);\n\n\t\tif (transferId === personalProjectToDelete.id) {\n\t\t\tthrow new BadRequestError(\n\t\t\t\t'Request to delete a user failed because the user to delete and the transferee are the same user',\n\t\t\t);\n\t\t}\n\n\t\tlet transfereeId;\n\t\tlet transfereeProject: Project | null = null;\n\n\t\tif (transferId) {\n\t\t\ttransfereeProject = await this.projectRepository.findOneBy({ id: transferId });\n\n\t\t\tif (!transfereeProject) {\n\t\t\t\tthrow new NotFoundError(\n\t\t\t\t\t'Request to delete a user failed because the transferee project was not found in DB',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst transfereeProjectId = transfereeProject.id;\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/users.controller.ts#L239-L275","documentation":"Thrown by DELETE /users/:id when the transferId query parameter equals the personal-project id of the user being deleted — i.e. the workflows/credentials would be transferred back to the same (personal) project being removed. HTTP 400. Fires after the existence and owner checks, after getPersonalProjectForUserOrFail resolves the to-be-deleted user's personal project.","triggerScenarios":"DELETE /users/<id>?transferId=<that-user's-personal-project-id>. The transfer target resolves to the user's own personal project.","commonSituations":"UI defaulting the transferee picker to the same user; client computing transferId from the target user's profile; misunderstanding that transferId is a project id, not a user id, and passing the target's personal-project id.","solutions":["Pass a transferId that belongs to a different user's personal project (or a shared project).","If you have only the transferee user id, resolve their personal project first via GET /users/<transferee-id> and use that project id.","Omit transferId entirely if you do not want to transfer (only do so if the user owns nothing)."],"exampleFix":"// before\nDELETE /users/123?transferId=<user-123-personal-project-id>\n// after\nDELETE /users/123?transferId=<user-456-personal-project-id>","handlingStrategy":"validation","validationCode":"function pickTransferProject(targetUserPersonalProjectId: string, candidates: string[]) {\n  return candidates.find((p) => p !== targetUserPersonalProjectId)\n    ?? (() => { throw new Error('transferee must differ from the deleted user'); })();\n}\n// pass a different user's personal project id as ?transferId=","typeGuard":null,"tryCatchPattern":"try { await fetch(`/rest/users/${id}?transferId=${pid}`, { method: 'DELETE' }); }\ncatch (e) { if (e.statusCode === 400 && /same user/.test(e.message)) { /* pick another project */ } else throw e; }","preventionTips":["transferId is a project id, not a user id.","Resolve the transferee's personal project via GET /users/<transferee-id> and use that id.","Ensure transferId != deleted user's personal project id."],"tags":["users","delete","ownership-transfer","rest-api","bad-request"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}