{"record":{"id":"1318a1309ef1e707","repo":"apache/dolphinscheduler","slug":"130020","errorCode":"130020","errorMessage":"Not allow to disable your own account","messagePattern":"Not allow to disable your own account","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java","lineNumber":391,"sourceCode":"                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        }\n\n        if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) {\n            throw new ServiceException(Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone);\n        }\n\n        if (state == 0 && user.getState() != state && Objects.equals(loginUser.getId(), user.getId())) {\n            throw new ServiceException(Status.NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT);\n        }\n\n        if (StringUtils.isNotEmpty(timeZone)) {\n            if (!CheckUtils.checkTimeZone(timeZone)) {\n                throw new ServiceException(Status.TIME_ZONE_ILLEGAL, timeZone);\n            }\n            user.setTimeZone(timeZone);\n        }\n\n        user.setPhone(phone);\n        user.setQueue(queue);\n        user.setState(state);\n        user.setUpdateTime(new Date());\n        user.setTenantId(tenantId);\n        // updateWorkflowInstance user\n        if (!userDao.updateById(user)) {\n            throw new ServiceException(Status.UPDATE_USER_ERROR);\n        }","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java#L373-L409","documentation":"Thrown by UsersServiceImpl.updateUser when an admin attempts to set state=0 (disabled) on their own account. The guard compares loginUser.getId() with the target user's id and rejects self-disabling with NOT_ALLOW_TO_DISABLE_OWN_ACCOUNT (code 130020), because it would lock the operator out of the system.","triggerScenarios":"Admin calls users/update with state=0 where the target user id equals the logged-in admin's own id and the account is currently enabled (state 1).","commonSituations":"Admin editing their own profile via the UI and toggling themselves to disabled; bulk scripts disabling users that include the admin account itself.","solutions":["Disable the account using a different admin account","Keep state=1 when updating your own user record","Exclude the currently logged-in user id from bulk-disable lists"],"exampleFix":"// before\nif (targetUser.getId() == loginUser.getId()) { state = 0; } // fails\n// after\nif (targetUser.getId() != loginUser.getId()) { state = 0; } // disable others only","handlingStrategy":"validation","validationCode":"if (state == 0 && targetUserId == loginUser.getId()) {\n    throw new IllegalStateException(\"cannot disable your own account\");\n}","typeGuard":null,"tryCatchPattern":"try { userService.updateUser(...); } catch (ServiceException e) { if (e.getCode() == 130020) { notify(\"Use another admin to disable this account\"); } }","preventionTips":["Disable the self-disable option in the UI when editing your own profile","Filter the logged-in user out of bulk-disable operations","Keep a second admin account available for recovery"],"tags":["user-management","authorization","state"],"backgroundTag":"invalid-state-transition","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"}