{"record":{"id":"21fd049baad7ab11","repo":"paascloud/paascloud-master","slug":"error-21fd04","errorCode":null,"errorMessage":"参数不能为空","messagePattern":"参数不能为空","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":280,"sourceCode":"\t\t}\n\n\t\tgroupBindUserDto.setAllUserSet(allUserSet);\n\t\tgroupBindUserDto.setAlreadyBindUserIdSet(alreadyBindUserIdSet);\n\n\t\treturn groupBindUserDto;\n\t}\n\n\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)) {","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java#L262-L298","documentation":"bindUacUser4Group validates its GroupBindUserReqDto argument before doing any work. If the request DTO itself is null, it logs and throws IllegalArgumentException(\"参数不能为空\") (parameter cannot be empty). This is an eager pre-condition check to fail fast instead of throwing an opaque NPE later.","triggerScenarios":"Calling UacGroupService.bindUacUser4Group(null, loginAuthDto) — the first argument (group bind request body) was never constructed, e.g. a controller passed an unbound @RequestBody or a caller built the DTO conditionally and skipped the null branch.","commonSituations":"REST clients POSTing an empty body to the group-bind-user endpoint so the deserialized DTO is null; upstream code refactors that removed DTO construction; test harnesses invoking the service directly without a request object.","solutions":["Ensure the caller constructs and passes a non-null GroupBindUserReqDto before invoking bindUacUser4Group.","At the controller layer, make the request body required (@RequestBody @Validated) so empty payloads are rejected with 400 before reaching the service.","Wrap the call in a null check or Optional.ofNullable and return a proper client error instead of letting the exception propagate."],"exampleFix":"// before\nuacGroupService.bindUacUser4Group(reqDto, loginAuthDto);\n// after\nif (reqDto == null) {\n    throw new BusinessException(\"bindUser request body is required\");\n}\nuacGroupService.bindUacUser4Group(reqDto, loginAuthDto);","handlingStrategy":"type-guard","validationCode":"if (reqDto == null || reqDto.getGroupId() == null || PublicUtil.isEmpty(reqDto.getUserIdList())) {\n    throw new IllegalArgumentException(\"groupBindUserReqDto and its fields are required\");\n}","typeGuard":"boolean isValidBindRequest(GroupBindUserReqDto dto) {\n    return dto != null && dto.getGroupId() != null && dto.getUserIdList() != null;\n}","tryCatchPattern":"try {\n    uacGroupService.bindUacUser4Group(reqDto, loginAuthDto);\n} catch (IllegalArgumentException e) {\n    return ResponseEntity.badRequest().body(\"request body required: \" + e.getMessage());\n}","preventionTips":["Always build the DTO explicitly; never pass a possibly-null variable straight into the service.","Enforce required request bodies at the controller with @RequestBody (default required=true).","Add unit tests that cover null-argument calls to service methods."],"tags":["null-argument","validation","java"],"backgroundTag":"null-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"}