paascloud/paascloud-master · error · IllegalArgumentException

参数不能为空

Error message

参数不能为空

What it means

In UacUserServiceImpl.bindUserRoles a null BindUserRolesDto causes logger.error("参数不能为空") and an IllegalArgumentException with the same message. This is a plain JDK exception (not UacBizException) signaling a programming/caller error: the mandatory request body is entirely missing.

Solutions

  1. Always construct and pass a populated BindUserRolesDto (userId + roleIdList) when calling the service
  2. On the client, send a valid JSON body with Content-Type: application/json
  3. Catch IllegalArgumentException around the call and return HTTP 400 'parameters cannot be empty'
  4. Add @Valid/@NotNull bean validation on the controller parameter so Spring rejects null bodies earlier

Example fix

// before
uacUserService.bindUserRoles(dto, authResDto); // dto may be null
// after
Preconditions.checkArgument(dto != null, "参数不能为空");
uacUserService.bindUserRoles(dto, authResDto);
Defensive patterns

Strategy: validation

Validate before calling

if (bindUserRolesDto == null) {
    throw new IllegalArgumentException("参数不能为空");
}

Type guard

if (bindUserRolesDto != null
        && bindUserRolesDto.getUserId() != null
        && bindUserRolesDto.getRoleIdList() != null) {
    uacUserService.bindUserRoles(bindUserRolesDto, authResDto);
}

Try / catch

try {
    uacUserService.bindUserRoles(dto, authResDto);
} catch (IllegalArgumentException e) {
    // return HTTP 400 'parameters cannot be empty'
}

Prevention

When it happens

Trigger: Calling bindUserRoles(null, authResDto), or a controller binding that yields a null @RequestBody when the client sends no body or an empty payload.

Common situations: Client POSTs without a JSON body or with wrong Content-Type so Spring cannot bind the DTO; internal code paths invoking the service before constructing the DTO; unit tests passing null.

Related errors


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

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacUserServiceImpl.java:282

			throw new UacBizException(ErrorCodeEnum.UAC10011023);
		}
		UacUser u = uacUserMapper.selectByPrimaryKey(userId);
		if (u == null) {
			throw new UacBizException(ErrorCodeEnum.UAC10011011, userId);
		}

		// 更新用户最后修改人与修改时间
		uacUser.setVersion(u.getVersion() + 1);
		uacUser.setUpdateInfo(authResDto);
		return uacUserMapper.updateByPrimaryKeySelective(uacUser);
	}

	@Override
	public void bindUserRoles(BindUserRolesDto bindUserRolesDto, LoginAuthDto authResDto) {

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

		Long operUserId = bindUserRolesDto.getUserId();
		Long loginUserId = authResDto.getUserId();
		List<Long> roleIdList = bindUserRolesDto.getRoleIdList();

		if (null == operUserId) {
			throw new UacBizException(ErrorCodeEnum.UAC10011001);
		}

		// 任何用户不能操作admin用户
		if (Objects.equals(operUserId, GlobalConstant.Sys.SUPER_MANAGER_USER_ID)) {
			throw new UacBizException(ErrorCodeEnum.UAC10011034);
		}

		UacUser user = this.queryByUserId(operUserId);

		if (user == null) {

View on GitHub (pinned to 781281a950)