paascloud/paascloud-master · error · UacBizException
UAC10012001
UAC10012001
Error message
角色ID不能为空
What it means
UacBizException UAC10012001 ('角色ID不能为空') thrown by UacRoleMenuServiceImpl.deleteByRoleId when roleId is null. Deleting role-menu bindings is keyed by roleId, so a null ID cannot identify rows and is rejected before the mapper delete runs.
Solutions
- Ensure a valid roleId is loaded before the delete call
- Skip deleteByRoleId when creating a brand-new role (nothing to delete)
- Validate roleId in the controller/service caller before delegating
Example fix
// before
uacRoleMenuService.deleteByRoleId(role.getId());
uacRoleMenuService.insert(role.getId(), menuIds);
// after
if (PublicUtil.isNotEmpty(role.getId())) {
uacRoleMenuService.deleteByRoleId(role.getId());
}
uacRoleMenuService.insert(role.getId(), menuIds); Defensive patterns
Strategy: validation
Validate before calling
if (roleId == null) {
return; // nothing to unbind for an unsaved role
} Type guard
boolean hasRole(Long roleId) { return roleId != null && roleId > 0; } Try / catch
try {
uacRoleMenuService.deleteByRoleId(roleId);
} catch (UacBizException e) {
if (ErrorCodeEnum.UAC10012001.getCode().equals(e.getCode())) {
logger.warn("deleteByRoleId called with null roleId");
return;
}
throw e;
} Prevention
- Skip unbind steps when creating new roles
- Validate path/request variables before service calls
- Keep unbind+rebind logic in one transactional method with a shared roleId check
When it happens
Trigger: Calling uacRoleMenuService.deleteByRoleId(null), typically from a role-update flow that first unbinds old menus but received no roleId (e.g. new role creation path mistakenly routed here).
Common situations: Role-edit page where a role was not yet saved; a copy-pasted unbind call in a create flow; deserialized DTO with missing roleId field.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/19243325b63c622f.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleMenuServiceImpl.java:39
@Service
@Transactional(rollbackFor = Exception.class)
public class UacRoleMenuServiceImpl extends BaseService<UacRoleMenu> implements UacRoleMenuService {
@Resource
private UacRoleMenuMapper uacRoleMenuMapper;
@Override
public int delRoleMenuList(Set<UacRoleMenu> uacRoleMenus) {
int result = 0;
for (UacRoleMenu uacRoleMenu : uacRoleMenus) {
result += uacRoleMenuMapper.delete(uacRoleMenu);
}
return result;
}
@Override
public void deleteByRoleId(Long roleId) {
if (roleId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10012001);
}
UacRoleMenu roleMenu = new UacRoleMenu();
roleMenu.setRoleId(roleId);
uacRoleMenuMapper.delete(roleMenu);
}
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UacRoleMenu> listByRoleId(Long roleId) {
if (roleId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10012001);
}
UacRoleMenu roleMenu = new UacRoleMenu();
roleMenu.setRoleId(roleId);
return uacRoleMenuMapper.select(roleMenu);
}
@OverrideView on GitHub (pinned to 781281a950)