paascloud/paascloud-master · error · IllegalArgumentException

参数不能为空

Error message

参数不能为空

What it means

bindUser4Role throws this IllegalArgumentException when the RoleBindUserReqDto argument itself is null. The service logs '参数不能为空' (parameter cannot be empty) before throwing. It is a guard against being called with no request object at all.

Solutions

  1. Ensure the caller constructs and passes a non-null RoleBindUserReqDto
  2. In the REST controller, annotate the body parameter with @RequestBody and validate it (@Valid/@NotNull) before invoking the service
  3. Catch IllegalArgumentException at the API boundary and return a 400-style response instead of a 500

Example fix

// before
uacRoleService.bindUser4Role(reqDto, loginAuthDto);
// after
if (reqDto == null) { throw new BusinessException("角色绑定请求不能为空"); }
uacRoleService.bindUser4Role(reqDto, loginAuthDto);
Defensive patterns

Strategy: validation

Validate before calling

if (reqDto == null) { throw new IllegalArgumentException("bindUser4Role request cannot be null"); }

Type guard

boolean isValid = dto != null;

Try / catch

try { service.bindUser4Role(dto, auth); } catch (IllegalArgumentException e) { return Response.badRequest(e.getMessage()); }

Prevention

When it happens

Trigger: Calling uacRoleService.bindUser4Role(null, authResDto), typically when an upstream controller passes an unbound/deserialization-failed request body.

Common situations: Feign/gateway calls with empty POST bodies, missing @RequestBody in the controller, or a caller constructing the DTO conditionally and forgetting to set it.

Related errors


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

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java:192

		List<UacRoleUser> setAlreadyBindUserSet = uacRoleUserService.listByRoleId(roleId);
		Set<BindUserDto> allUserSet = new HashSet<>(bindUserDtoList);

		for (UacRoleUser uacRoleUser : setAlreadyBindUserSet) {
			alreadyBindUserIdSet.add(uacRoleUser.getUserId());
		}

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

		return roleBindUserDto;
	}

	@Override
	public void bindUser4Role(RoleBindUserReqDto roleBindUserReqDto, LoginAuthDto authResDto) {

		if (roleBindUserReqDto == null) {
			logger.error("参数不能为空");
			throw new IllegalArgumentException("参数不能为空");
		}

		Long roleId = roleBindUserReqDto.getRoleId();
		Long loginUserId = authResDto.getUserId();
		List<Long> userIdList = roleBindUserReqDto.getUserIdList();

		if (null == roleId) {
			throw new IllegalArgumentException(ErrorCodeEnum.UAC10012001.msg());
		}

		UacRole role = this.getRoleById(roleId);

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

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

View on GitHub (pinned to 781281a950)