paascloud/paascloud-master · error · UacBizException
UAC10012006
UAC10012006
Error message
ErrorCodeEnum.UAC10012006
What it means
UacBizException with code UAC10012006 (role-user delete by roleId failed) thrown by deleteByRoleId when the delete statement affects zero rows. The service expects at least one role-user binding to be removed for the given roleId.
Solutions
- Check that the role actually has user bindings before calling deleteByRoleId (query listByRoleId first).
- Treat deletion of an empty role as a no-op: skip the call when listByRoleId(roleId) is empty.
- Confirm the roleId is correct; inspect the message's roleId against the database.
Example fix
// before
uacRoleUserService.deleteByRoleId(roleId);
// after
if (PublicUtil.isNotEmpty(uacRoleUserService.listByRoleId(roleId))) {
uacRoleUserService.deleteByRoleId(roleId);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (PublicUtil.isEmpty(uacRoleUserService.listByRoleId(roleId))) { return; }
uacRoleUserService.deleteByRoleId(roleId); Type guard
boolean deletable = roleId != null && !Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);
Try / catch
try {
uacRoleUserService.deleteByRoleId(roleId);
} catch (UacBizException e) {
if ("UAC10012006".equals(e.getCode())) { log.info("no bindings for roleId {}", roleId); return; }
throw e;
} Prevention
- Skip deletion when the role has no bindings
- Make deletes idempotent — treat zero rows as success
- Verify roleId correctness before invoking delete
When it happens
Trigger: deleteByRoleId(roleId) where the role has no assigned users — the mapper's deleteByRoleId returns 0 and the service raises the exception with the roleId in the message.
Common situations: Deleting bindings for a role that never had users; the bindings were already deleted by a prior request or another admin; roleId typo pointing to a different role.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/87e569aab1c245c1.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java:147
@Override
public void deleteByRoleIdList(List<Long> roleIdList) {
Preconditions.checkArgument(PublicUtil.isNotEmpty(roleIdList), ErrorCodeEnum.UAC10012001.msg());
Preconditions.checkArgument(!roleIdList.contains(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID), "超级管理员角色不能删除");
int result = uacRoleUserMapper.deleteByRoleIdList(roleIdList);
if (result < roleIdList.size()) {
throw new UacBizException(ErrorCodeEnum.UAC10012007, Joiner.on(GlobalConstant.Symbol.COMMA).join(roleIdList));
}
}
@Override
public void deleteByRoleId(Long roleId) {
Preconditions.checkArgument(roleId != null, ErrorCodeEnum.UAC10012001.msg());
Preconditions.checkArgument(!Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID), "超级管理员角色不能删除");
int result = uacRoleUserMapper.deleteByRoleId(roleId);
if (result < 1) {
throw new UacBizException(ErrorCodeEnum.UAC10012006, roleId);
}
}
}
View on GitHub (pinned to 781281a950)