{"record":{"id":"a9a5b502792ae07b","repo":"apache/dolphinscheduler","slug":"10003","errorCode":"10003","errorMessage":"user name already exists","messagePattern":"user name already exists","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java","lineNumber":366,"sourceCode":"        if (!isAdmin(loginUser)) {\n            if (tenantId != null && user.getTenantId() != tenantId) {\n                throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n            }\n            if (StringUtils.isNotEmpty(queue) && !StringUtils.equals(queue, user.getQueue())) {\n                throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n            }\n        }\n\n        if (StringUtils.isNotEmpty(userName)) {\n\n            if (!CheckUtils.checkUserName(userName)) {\n                throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);\n            }\n\n            // todo: use the db unique index\n            User tempUser = userDao.queryByUserNameAccurately(userName);\n            if (tempUser != null && !userId.equals(tempUser.getId())) {\n                throw new ServiceException(Status.USER_NAME_EXIST);\n            }\n            user.setUserName(userName);\n        }\n\n        if (StringUtils.isNotEmpty(userPassword)) {\n            if (!CheckUtils.checkPasswordLength(userPassword)) {\n                throw new ServiceException(Status.USER_PASSWORD_LENGTH_ERROR);\n            }\n            user.setUserPassword(EncryptionUtils.getMd5(userPassword));\n            sessionService.expireSession(user.getId());\n        }\n\n        if (StringUtils.isNotEmpty(email)) {\n            if (!CheckUtils.checkEmail(email)) {\n                throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, email);\n            }\n            user.setEmail(email);\n        }","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java#L348-L384","documentation":"Thrown by UsersServiceImpl.updateUser when the new userName already belongs to another user: queryByUserNameAccurately finds an existing row whose id differs from the userId being updated. Usernames are unique in t_ds_user, so the rename is rejected with USER_NAME_EXIST. Note the code comment: the check is application-level; a DB unique index is the intended backstop.","triggerScenarios":"Renaming a user to a name taken by another account (or a deleted-but-recreated one); concurrent renames by two admins to the same name; case-sensitivity mismatches if the DB collation is case-insensitive but the Java check is not (or vice versa).","commonSituations":"LDAP sync colliding with manually created users; restoring exports that reuse names; automation retrying a create that half-succeeded earlier.","solutions":["Pick a different userName, or append a suffix to make it unique","Check the existing user with queryByUserNameAccurately / GET /users to see who owns the name","If the name belongs to a stale account, delete/deactivate that account first","Rely on the DB unique constraint catch as a second guard for concurrent renames"],"exampleFix":"// before\nusersService.updateUser(loginUser, userId, \"alice\", ...); // 'alice' already exists\n// after\nif (userDao.queryByUserNameAccurately(\"alice\") != null) {\n    name = \"alice_2\"; // or prompt caller for a unique name\n}\nusersService.updateUser(loginUser, userId, name, ...);","handlingStrategy":"validation","validationCode":"User existing = userDao.queryByUserNameAccurately(newUserName);\nif (existing != null && !existing.getId().equals(userId)) {\n    throw new IllegalArgumentException(\"userName '\" + newUserName + \"' is already taken\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    usersService.updateUser(loginUser, userId, userName, ...);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.USER_NAME_EXIST.getCode()) {\n        // propose a unique alternative name to the caller\n    } else { throw e; }\n}","preventionTips":["Check name availability in the UI before submit","Add unique suffixes in bulk-import pipelines","Catch DB unique-constraint violations as a backstop for concurrent renames"],"tags":["uniqueness","username","conflict","dolphinscheduler"],"backgroundTag":"user-name-already-exists","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}