paascloud/paascloud-master · error · IllegalArgumentException

組織ID不能为空

Error message

組織ID不能为空

What it means

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.

Solutions

  1. Set groupId on the GroupBindUserReqDto before calling the service.
  2. Add @NotNull on groupId (with @Validated in the controller) so the request is rejected at the boundary with a clear message.
  3. Have the client derive groupId from the currently selected organization node and include it in the payload.

Example fix

// before
GroupBindUserReqDto req = new GroupBindUserReqDto();
req.setUserIdList(userIds);
uacGroupService.bindUacUser4Group(req, loginAuthDto);
// after
GroupBindUserReqDto req = new GroupBindUserReqDto();
req.setGroupId(group.getId());
req.setUserIdList(userIds);
uacGroupService.bindUacUser4Group(req, loginAuthDto);
Defensive patterns

Strategy: validation

Validate before calling

if (req.getGroupId() == null) {
    throw new IllegalArgumentException("groupId is required to bind users to a group");
}

Type guard

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

Try / catch

try {
    uacGroupService.bindUacUser4Group(req, loginAuthDto);
} catch (IllegalArgumentException e) {
    return ResponseEntity.badRequest().body("missing groupId: " + e.getMessage());
}

Prevention

When it happens

Trigger: Calling bindUacUser4Group with a GroupBindUserReqDto whose groupId field was never set (new GroupBindUserReqDto with only userIdList populated), or JSON payload missing the groupId property.

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

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

	/**
	 * 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)) {
			logger.error("不能操作当前登录用户 userId={}", loginUserId);
			throw new UacBizException(ErrorCodeEnum.UAC10011023);
		}

		// 查询超级管理员用户Id集合
		List<Long> superUserList = uacRoleUserMapper.listSuperUser(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
		List<Long> unionList = Collections3.intersection(userIdList, superUserList);
		if (PublicUtil.isNotEmpty(userIdList) && PublicUtil.isNotEmpty(unionList)) {

View on GitHub (pinned to 781281a950)