paascloud/paascloud-master · error · UacBizException
UAC10011001
UAC10011001
Error message
ErrorCodeEnum.UAC10011001
What it means
UAC10011001 is thrown when the userId argument passed to getOwnAuthTree is null. The UAC (User Authentication Center) role service requires a concrete user id to build the list of MenuVo entries the user is authorized for; without it no menu query can be performed. This is a fail-fast argument validation before delegating to uacMenuService.getMenuVoList.
Solutions
- Ensure the userId is resolved from the authenticated session/principal before calling getOwnAuthTree
- Validate/Preconditions.checkNotNull the userId at the controller or caller layer
- Check that the login user context (e.g. WrappedUser / request header) is populated; fix authentication if it is null
- If null legitimately means 'no user', return an empty list or an auth error instead of passing null through
Example fix
// before Long userId = getLoginUserId(); // may return null List<MenuVo> menus = uacRoleService.getOwnAuthTree(userId); // after Long userId = getLoginUserId(); Preconditions.checkNotNull(userId, "login userId must not be null"); List<MenuVo> menus = uacRoleService.getOwnAuthTree(userId);
Defensive patterns
Strategy: validation
Validate before calling
if (userId == null) { throw new IllegalArgumentException("userId must not be null"); } Type guard
boolean userIdPresent(Long userId) { return userId != null && userId > 0; } Try / catch
try { return uacRoleService.getOwnAuthTree(userId); } catch (UacBizException e) { if ("UAC10011001".equals(e.getCode())) { throw new BadRequestException("userId is required"); } throw e; } Prevention
- Always derive userId from the authenticated principal, never from client-supplied nullable fields
- Null-check user context at the controller/filter layer before entering services
- Use Preconditions.checkNotNull for required arguments in service callers
- Add unit tests covering null userId for menu-authorization endpoints
When it happens
Trigger: Calling UacRoleService.getOwnAuthTree(null), typically when the caller's session user id was never populated (unauthenticated request, missing login user context, or a DTO field that was never set).
Common situations: Developers hit this when the current-user lookup (e.g. from security context or request header) silently returns null, when integrating the API without authentication, or when copying service code and forgetting to resolve the userId from the logged-in principal.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/db7cb397c71392bb.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java:336
List<UacRoleUser> uruList = uacRoleUserService.listByRoleIdList(roleIdList);
if (!uruList.isEmpty()) {
uacRoleUserService.deleteByRoleIdList(roleIdList);
}
uacRoleMenuService.deleteByRoleIdList(roleIdList);
uacRoleActionService.deleteByRoleIdList(roleIdList);
int result = uacRoleMapper.batchDeleteByIdList(roleIdList);
if (result < roleIdList.size()) {
throw new UacBizException(ErrorCodeEnum.UAC10012006, Joiner.on(GlobalConstant.Symbol.COMMA).join(roleIdList));
}
}
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<MenuVo> getOwnAuthTree(Long userId) {
if (userId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10011001);
}
return uacMenuService.getMenuVoList(userId, GlobalConstant.Sys.OPER_APPLICATION_ID);
}
@Override
public void bindMenu(RoleBindMenuDto roleBindMenuDto) {
Long roleId = roleBindMenuDto.getRoleId();
Set<Long> menuIdList = roleBindMenuDto.getMenuIdList();
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);View on GitHub (pinned to 781281a950)