paascloud/paascloud-master · error · UacBizException
UAC10012008
UAC10012008
Error message
ErrorCodeEnum.UAC10012008
What it means
UAC10012008 is thrown by UacUserServiceImpl.bindUserRoles when one of the role IDs submitted for binding to a user does not exist in the UAC role table. The service looks up each role via uacRoleService.getRoleById(roleId); a null result means the caller passed a stale, deleted, or fabricated roleId. The exception aborts the whole bind operation before any saveRoleUser for the offending id (though earlier roles in the loop may already be saved).
Solutions
- Refresh the role list from the server and ensure every roleId in the payload exists before calling bindUserRoles
- Delete or correct the offending entry in roleIdList (the exception can be caught and its args inspected to find the bad roleId)
- Verify the role exists in the DB: SELECT * FROM uac_role WHERE id = ?
- If roles were deleted legitimately, propagate deletions to any UI/state that caches role ids
Example fix
// before uacRoleService.bindUserRoles(userId, roleIds); // roleIds from stale client cache // after List<Long> validIds = roleService.findAllIds(); roleIds = roleIds.stream().filter(validIds::contains).collect(Collectors.toList()); uacRoleService.bindUserRoles(userId, roleIds);
Defensive patterns
Strategy: validation
Validate before calling
for (Long roleId : roleIdList) {
if (uacRoleService.getRoleById(roleId) == null) {
throw new IllegalArgumentException("role not found: " + roleId);
}
} Type guard
boolean roleExists(Long roleId) { return uacRoleService.getRoleById(roleId) != null; } Try / catch
try { uacUserService.bindUserRoles(userId, roleIds); } catch (UacBizException e) { if ("UAC10012008".equals(e.getCode())) { /* reload role list, notify invalid roleId */ } } Prevention
- Always load role ids from a fresh server-side list, never trust stale client caches
- Validate all roleIds exist before invoking bindUserRoles
- Handle role deletion by cascading removal from cached role selections
When it happens
Trigger: Calling bindUserRoles(userId, roleIdList) where roleIdList contains a roleId that was deleted, belongs to another tenant, or was never created; passing client-supplied role ids without validating they exist.
Common situations: Stale frontend caches of role lists after an admin deleted a role; concurrent deletion of a role between listing and binding; clients fabricating or mis-typing role ids; data migration leaving orphaned role references.
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/d588c4c125d047d1.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacUserServiceImpl.java:334
// 更新用户的操作时间
final UacUser updateUser = new UacUser();
updateUser.setId(operUserId);
updateUser.setUpdateInfo(authResDto);
uacUserMapper.updateUacUser(updateUser);
if (PublicUtil.isEmpty(roleIdList)) {
// 取消该角色的所有用户的绑定
logger.info("绑定角色成功");
return;
}
// 绑定所选用户
for (Long roleId : roleIdList) {
UacRole uacRole = uacRoleService.getRoleById(roleId);
if (uacRole == null) {
logger.error("找不到绑定的角色. roleId={}", roleId);
throw new UacBizException(ErrorCodeEnum.UAC10012008, roleId);
}
uacRoleUserService.saveRoleUser(operUserId, roleId);
}
}
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UserMenuDto> queryUserMenuDtoData(LoginAuthDto authResDto) {
// 返回的结果集
List<UserMenuDto> list = Lists.newArrayList();
List<MenuVo> menuList; // 该用户下所有的菜单集合
Long userId = authResDto.getUserId();
List<Long> ownerMenuIdList = Lists.newArrayList();
Preconditions.checkArgument(!PubUtils.isNull(authResDto, userId), "无访问权限");
// 查询该用户下所有的菜单Id集合
UacUserMenu query = new UacUserMenu();
query.setUserId(userId);View on GitHub (pinned to 781281a950)