paascloud/paascloud-master · error · IllegalArgumentException

参数不能为空

Error message

参数不能为空

What it means

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.

Solutions

  1. Ensure the caller constructs and passes a non-null GroupBindUserReqDto before invoking bindUacUser4Group.
  2. At the controller layer, make the request body required (@RequestBody @Validated) so empty payloads are rejected with 400 before reaching the service.
  3. Wrap the call in a null check or Optional.ofNullable and return a proper client error instead of letting the exception propagate.

Example fix

// before
uacGroupService.bindUacUser4Group(reqDto, loginAuthDto);
// after
if (reqDto == null) {
    throw new BusinessException("bindUser request body is required");
}
uacGroupService.bindUacUser4Group(reqDto, loginAuthDto);
Defensive patterns

Strategy: type-guard

Validate before calling

if (reqDto == null || reqDto.getGroupId() == null || PublicUtil.isEmpty(reqDto.getUserIdList())) {
    throw new IllegalArgumentException("groupBindUserReqDto and its fields are required");
}

Type guard

boolean isValidBindRequest(GroupBindUserReqDto dto) {
    return dto != null && dto.getGroupId() != null && dto.getUserIdList() != null;
}

Try / catch

try {
    uacGroupService.bindUacUser4Group(reqDto, loginAuthDto);
} catch (IllegalArgumentException e) {
    return ResponseEntity.badRequest().body("request body required: " + e.getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/21fd049baad7ab11. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java:280

		}

		groupBindUserDto.setAllUserSet(allUserSet);
		groupBindUserDto.setAlreadyBindUserIdSet(alreadyBindUserIdSet);

		return groupBindUserDto;
	}

	/**
	 * Bind uac user 4 group int.
	 *
	 * @param groupBindUserReqDto the group bind user req dto
	 * @param authResDto          the auth res dto
	 */
	@Override
	public void bindUacUser4Group(GroupBindUserReqDto groupBindUserReqDto, LoginAuthDto authResDto) {
		if (groupBindUserReqDto == null) {
			logger.error("参数不能为空");
			throw new IllegalArgumentException("参数不能为空");
		}

		Long groupId = groupBindUserReqDto.getGroupId();
		Long loginUserId = authResDto.getUserId();
		List<Long> userIdList = groupBindUserReqDto.getUserIdList();

		if (null == groupId) {
			throw new IllegalArgumentException("組織ID不能为空");
		}

		UacGroup group = uacGroupMapper.selectByPrimaryKey(groupId);

		if (group == null) {
			logger.error("找不到角色信息 groupId={}", groupId);
			throw new UacBizException(ErrorCodeEnum.UAC10015001, groupId);
		}

		if (PublicUtil.isNotEmpty(userIdList) && userIdList.contains(loginUserId)) {

View on GitHub (pinned to 781281a950)