paascloud/paascloud-master · error · UacBizException

UAC10015009

UAC10015009

Error message

找不到上级组织, groupId=%s

What it means

saveUacGroup requires the new/updated group to reference an existing parent. After asserting pid is non-empty, it loads the parent with uacGroupMapper.selectByPrimaryKey(group.getPid()); if absent it throws UacBizException(UAC10015009) "找不到上级组织, groupId=%s" (parent organization not found). This enforces the organization tree's referential integrity.

Solutions

  1. Create/verify the parent organization exists before saving the child (parent-first insertion order).
  2. Check the pid value — if creating a root-level group, use the correct root id convention rather than an arbitrary pid.
  3. Catch UacBizException UAC10015009 and prompt the user to pick a valid parent node from a freshly loaded tree.

Example fix

// before
UacGroup child = new UacGroup();
child.setPid(12345L); // parent may not exist
uacGroupService.saveUacGroup(child, loginAuthDto);
// after
UacGroup parent = uacGroupService.getById(parentId); // throws if missing
UacGroup child = new UacGroup();
child.setPid(parent.getId());
uacGroupService.saveUacGroup(child, loginAuthDto);
Defensive patterns

Strategy: validation

Validate before calling

if (StringUtils.isEmpty(group.getPid()) || uacGroupMapper.selectByPrimaryKey(group.getPid()) == null) {
    throw new BusinessException("parent group " + group.getPid() + " must exist before saving child");
}

Type guard

null

Try / catch

try {
    uacGroupService.saveUacGroup(group, loginAuthDto);
} catch (UacBizException e) {
    if (ErrorCodeEnum.UAC10015009.getCode().equals(e.getCode())) {
        return ResponseEntity.status(404).body("parent organization not found; pick a valid parent node");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling saveUacGroup with a pid that does not exist — parent deleted first, pid copied from another environment, or client sending pid=0/placeholder value that passes the non-empty check.

Common situations: Import/migration scripts creating children before parents; UI tree cache holding deleted nodes; seeding scripts assuming a root group id that wasn't created.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — 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/5c4eebee9db30d90. Report an issue: GitHub.

Appendix: source

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

				logger.error("找不到绑定的用户 userId={}", userId);
				throw new UacBizException(ErrorCodeEnum.UAC10011024, userId);
			}
			UacGroupUser uacGroupUser = new UacGroupUser();
			uacGroupUser.setUserId(userId);
			uacGroupUser.setGroupId(groupId);
			uacGroupUserMapper.insertSelective(uacGroupUser);
		}
	}

	@Override
	public int saveUacGroup(UacGroup group, LoginAuthDto loginAuthDto) {

		int result;
		Preconditions.checkArgument(!StringUtils.isEmpty(group.getPid()), "上级节点不能为空");

		UacGroup parenGroup = uacGroupMapper.selectByPrimaryKey(group.getPid());
		if (PublicUtil.isEmpty(parenGroup)) {
			throw new UacBizException(ErrorCodeEnum.UAC10015009, group.getPid());
		}
		setGroupAddress(group);
		group.setUpdateInfo(loginAuthDto);

		if (group.isNew()) {
			Long groupId = super.generateId();
			group.setId(groupId);
			group.setLevel(parenGroup.getLevel() + 1);
			result = this.addUacGroup(group);
		} else {
			result = this.editUacGroup(group);
		}
		return result;
	}

	@Override
	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public UacGroup getById(Long id) {

View on GitHub (pinned to 781281a950)