{"record":{"id":"bf301cb637e8564c","repo":"paascloud/paascloud-master","slug":"id-bf301c","errorCode":null,"errorMessage":"組織ID不能为空","messagePattern":"組織ID不能为空","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java","lineNumber":288,"sourceCode":"\t/**\n\t * Bind uac user 4 group int.\n\t *\n\t * @param groupBindUserReqDto the group bind user req dto\n\t * @param authResDto          the auth res dto\n\t */\n\t@Override\n\tpublic void bindUacUser4Group(GroupBindUserReqDto groupBindUserReqDto, LoginAuthDto authResDto) {\n\t\tif (groupBindUserReqDto == null) {\n\t\t\tlogger.error(\"参数不能为空\");\n\t\t\tthrow new IllegalArgumentException(\"参数不能为空\");\n\t\t}\n\n\t\tLong groupId = groupBindUserReqDto.getGroupId();\n\t\tLong loginUserId = authResDto.getUserId();\n\t\tList<Long> userIdList = groupBindUserReqDto.getUserIdList();\n\n\t\tif (null == groupId) {\n\t\t\tthrow new IllegalArgumentException(\"組織ID不能为空\");\n\t\t}\n\n\t\tUacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);\n\n\t\tif (group == null) {\n\t\t\tlogger.error(\"找不到角色信息 groupId={}\", groupId);\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10015001, groupId);\n\t\t}\n\n\t\tif (PublicUtil.isNotEmpty(userIdList) && userIdList.contains(loginUserId)) {\n\t\t\tlogger.error(\"不能操作当前登录用户 userId={}\", loginUserId);\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011023);\n\t\t}\n\n\t\t// 查询超级管理员用户Id集合\n\t\tList<Long> superUserList = uacRoleUserMapper.listSuperUser(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);\n\t\tList<Long> unionList = Collections3.intersection(userIdList, superUserList);\n\t\tif (PublicUtil.isNotEmpty(userIdList) && PublicUtil.isNotEmpty(unionList)) {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java#L270-L306","documentation":"After the null-DTO check, bindUacUser4Group extracts groupId from the request. If groupId is null it throws IllegalArgumentException(\"組織ID不能为空\") (organization ID cannot be empty). The group id is mandatory because all subsequent lookups and unbind/bind operations are scoped to it.","triggerScenarios":"Calling bindUacUser4Group with a GroupBindUserReqDto whose groupId field was never set (new GroupBindUserReqDto with only userIdList populated), or JSON payload missing the groupId property.","commonSituations":"Front-end forms submitting only the selected user list and omitting the hidden groupId field; API consumers copying another team's DTO where the field was renamed; deserialization silently leaving the field null on type mismatch.","solutions":["Set groupId on the GroupBindUserReqDto before calling the service.","Add @NotNull on groupId (with @Validated in the controller) so the request is rejected at the boundary with a clear message.","Have the client derive groupId from the currently selected organization node and include it in the payload."],"exampleFix":"// before\nGroupBindUserReqDto req = new GroupBindUserReqDto();\nreq.setUserIdList(userIds);\nuacGroupService.bindUacUser4Group(req, loginAuthDto);\n// after\nGroupBindUserReqDto req = new GroupBindUserReqDto();\nreq.setGroupId(group.getId());\nreq.setUserIdList(userIds);\nuacGroupService.bindUacUser4Group(req, loginAuthDto);","handlingStrategy":"validation","validationCode":"if (req.getGroupId() == null) {\n    throw new IllegalArgumentException(\"groupId is required to bind users to a group\");\n}","typeGuard":"boolean hasGroupId(GroupBindUserReqDto dto) {\n    return dto != null && dto.getGroupId() != null;\n}","tryCatchPattern":"try {\n    uacGroupService.bindUacUser4Group(req, loginAuthDto);\n} catch (IllegalArgumentException e) {\n    return ResponseEntity.badRequest().body(\"missing groupId: \" + e.getMessage());\n}","preventionTips":["Annotate DTO fields with @NotNull and validate with @Validated at the controller boundary.","Have the client always include the selected organization node id in the payload.","Add contract tests asserting groupId is serialized in bind requests."],"tags":["validation","missing-required-argument","java"],"backgroundTag":"missing-required-argument","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}