{"record":{"id":"f7289ec0a20aa3c3","repo":"apolloconfig/apollo","slug":"username-and-password-can-not-be-empty","errorCode":null,"errorMessage":"Username and password can not be empty.","messagePattern":"Username and password can not be empty\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/UserController.java","lineNumber":96,"sourceCode":"  }\n\n  @Override\n  public ResponseEntity<OpenUserInfoDTO> getUserByUserId(String userId) {\n    requireUserManagementReadPermission();\n    UserInfo user = userService.findByUserId(userId);\n    if (user == null) {\n      throw BadRequestException.userNotExists(userId);\n    }\n    return ResponseEntity.ok(OpenApiModelConverters.fromUserInfo(user));\n  }\n\n  @Override\n  public ResponseEntity<Void> createOrUpdateUser(OpenUserDTO openUserDTO, Boolean isCreate,\n      String operator) {\n    boolean consumerRequest = requireUserManagementMutationPermission(operator);\n    UserPO user = OpenApiModelConverters.toUserPO(openUserDTO);\n    if (StringUtils.isContainEmpty(user.getUsername(), user.getPassword())) {\n      throw new BadRequestException(\"Username and password can not be empty.\");\n    }\n\n    if (!consumerRequest && !unifiedPermissionValidator.isSuperAdmin()\n        && (!user.getUsername().equals(userInfoHolder.getUser().getUserId())\n            || user.getEnabled() != USER_ENABLED)) {\n      throw new AccessDeniedException(\"Create or update user operation is forbidden\");\n    }\n\n    CheckResult pwdCheckRes = passwordChecker.checkWeakPassword(user.getPassword());\n    if (!pwdCheckRes.isSuccess()) {\n      throw new BadRequestException(pwdCheckRes.getMessage());\n    }\n\n    if (userService instanceof SpringSecurityUserService) {\n      if (Boolean.TRUE.equals(isCreate)) {\n        ((SpringSecurityUserService) userService).create(user);\n      } else {\n        ((SpringSecurityUserService) userService).update(user);","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/UserController.java#L78-L114","documentation":"Thrown by createOrUpdateUser when the converted user has an empty username or password. StringUtils.isContainEmpty treats null, empty, and whitespace-only values as empty.","triggerScenarios":"Thrown when the create-or-update user OpenAPI endpoint is called with a blank username or blank password in the request body.","commonSituations":"Client omitted username/password fields; empty strings sent in the JSON payload.","solutions":["Provide both username and password in the OpenUserDTO payload; neither may be null, empty, or whitespace.","Verify the request body is serialized correctly and the fields map to username/password as defined by the OpenAPI spec."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}