{"record":{"id":"69d1692923813173","repo":"apolloconfig/apollo","slug":"userids-should-not-be-null-or-empty","errorCode":null,"errorMessage":"userIds should not be null or empty","messagePattern":"userIds should not be null or empty","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerPermissionOpenApiService.java","lineNumber":232,"sourceCode":"  public void assignAppRoleToUser(String appId, String roleType, String userId, String operator) {\n    assignRole(RoleUtils.buildAppRoleName(appId, roleType), roleType, userId, operator);\n  }\n\n  @Override\n  public void removeAppRoleFromUser(String appId, String roleType, String userId, String operator) {\n    removeRole(RoleUtils.buildAppRoleName(appId, roleType), roleType, userId, operator);\n  }\n\n  @Override\n  public Map<String, Boolean> hasCreateApplicationPermission(String userId) {\n    return Collections.singletonMap(HAS_CREATE_APPLICATION_PERMISSION,\n        systemRoleManagerService.hasCreateApplicationPermission(userId));\n  }\n\n  @Override\n  public void addCreateApplicationRoleToUsers(List<String> userIds, String operator) {\n    if (CollectionUtils.isEmpty(userIds)) {\n      throw new BadRequestException(\"userIds should not be null or empty\");\n    }\n    userIds.forEach(this::checkUserExists);\n    rolePermissionService.assignRoleToUsers(SystemRoleManagerService.CREATE_APPLICATION_ROLE_NAME,\n        new HashSet<>(userIds), operator);\n  }\n\n  @Override\n  public void deleteCreateApplicationRoleFromUser(String userId, String operator) {\n    RequestPrecondition.checkArgumentsNotEmpty(userId);\n    checkUserExists(userId);\n    rolePermissionService.removeRoleFromUsers(SystemRoleManagerService.CREATE_APPLICATION_ROLE_NAME,\n        Sets.newHashSet(userId), operator);\n  }\n\n  @Override\n  public List<String> getCreateApplicationRoleUsers() {\n    Set<UserInfo> users = rolePermissionService\n        .queryUsersWithRole(SystemRoleManagerService.CREATE_APPLICATION_ROLE_NAME);","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/server/service/ServerPermissionOpenApiService.java#L214-L250","documentation":"Thrown as BadRequestException (HTTP 400) by ServerPermissionOpenApiService.addCreateApplicationRoleToUsers when the userIds list is null or empty (CollectionUtils.isEmpty). Assigning the create-application role requires at least one target user.","triggerScenarios":"Calling addCreateApplicationRoleToUsers(userIds, operator) with an empty list or null.","commonSituations":"Caller built the list from a filter that returned no users; deserialization producing an empty array; guard missing at the API client.","solutions":["Validate userIds is non-empty before calling.","Short-circuit (no-op) in the caller when there are no users to authorize."],"exampleFix":"// before\npermissionService.addCreateApplicationRoleToUsers(filteredUsers, operator); // 400 if filteredUsers empty\n// after\nif (!filteredUsers.isEmpty()) {\n  permissionService.addCreateApplicationRoleToUsers(filteredUsers, operator);\n}","handlingStrategy":"validation","validationCode":"if (!CollectionUtils.isEmpty(userIds)) {\n  permissionService.addCreateApplicationRoleToUsers(userIds, operator);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Short-circuit when there are no users to authorize.","Validate list inputs at the API boundary before delegation."],"tags":["permissions","validation","bad-request","apollo-portal","openapi"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}