paascloud/paascloud-master · error · UacBizException
UAC10012005
UAC10012005
Error message
找不到角色信息,roleId=%s
What it means
UacBizException UAC10012005 ('找不到角色信息,roleId=%s') thrown by UacRoleServiceImpl.bindAction when uacRoleMapper.selectByPrimaryKey(roleId) returns null. The roleId passed the null check but no role row exists with that ID, formatted with the offending roleId.
Solutions
- Verify the roleId exists (select from uac_role) in the target environment before binding
- Refresh the client's role list after deletes
- Confirm the service is pointed at the intended database/datasource
Example fix
// before
uacRoleService.bindAction(dto); // throws if role was deleted
// after
UacRole role = uacRoleMapper.selectByPrimaryKey(dto.getRoleId());
if (role != null) {
uacRoleService.bindAction(dto);
} else {
throw new BusinessException("role " + dto.getRoleId() + " no longer exists");
} Defensive patterns
Strategy: try-catch
Validate before calling
UacRole role = uacRoleMapper.selectByPrimaryKey(roleId);
if (role == null) {
return Result.error("角色不存在: " + roleId);
} Type guard
boolean roleExists(UacRoleMapper mapper, Long roleId) { return roleId != null && mapper.selectByPrimaryKey(roleId) != null; } Try / catch
try {
uacRoleService.bindAction(dto);
} catch (UacBizException e) {
if (ErrorCodeEnum.UAC10012005.getCode().equals(e.getCode())) {
return Result.error("角色不存在,请刷新角色列表");
}
throw e;
} Prevention
- Refresh role caches/lists after deletes
- Verify environment-specific role IDs before scripted calls
- Validate foreign-key references before cross-service writes
- Confirm the datasource points at the intended environment
When it happens
Trigger: bindAction called with a roleId that does not exist in the uac_role table — deleted role, wrong database/environment, or fabricated ID in the request.
Common situations: Client caching a role list while another admin deleted the role; multi-environment deployment using IDs from another DB; typos in hardcoded IDs in scripts or tests.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/b9f193c826cdc483.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java:136
@Override
public void bindAction(RoleBindActionDto grantAuthRole) {
Long roleId = grantAuthRole.getRoleId();
Set<Long> actionIdList = grantAuthRole.getActionIdList();
if (roleId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10012001);
}
if (Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID)) {
logger.error("越权操作, 超级管理员用户不允许操作");
throw new UacBizException(ErrorCodeEnum.UAC10011023);
}
UacRole uacRole = uacRoleMapper.selectByPrimaryKey(roleId);
if (uacRole == null) {
logger.error("找不到角色信息. roleId={}", roleId);
throw new UacBizException(ErrorCodeEnum.UAC10012005, roleId);
}
// TODO 校验参数的合法性(这里不写了 累得慌 也就是校验菜单和权限是否存在)
List<UacRoleAction> uacRoleActionList = uacRoleActionService.listByRoleId(roleId);
if (PublicUtil.isNotEmpty(uacRoleActionList)) {
uacRoleActionService.deleteByRoleId(roleId);
}
if (PublicUtil.isEmpty(actionIdList)) {
logger.error("传入按钮权限Id为空, 取消所有按钮权限");
} else {
// 绑定权限
uacRoleActionService.insert(roleId, actionIdList);
}
}
@OverrideView on GitHub (pinned to 781281a950)