paascloud/paascloud-master · error · UacBizException
UAC10013002
UAC10013002
Error message
更新上级菜单失败,menuId=%s
What it means
UacBizException UAC10013002 thrown by UacMenuServiceImpl.saveUacMenu when saving a new menu fails to update its parent menu row. After inserting the child menu, the service marks the parent as non-leaf (updateMenu.setLeaf(MENU_LEAF_NO)) and issues updateByPrimaryKeySelective; if the update affects fewer than 1 row, the parent record was not found or the update failed. Message includes the parent menuId for diagnosis.
Solutions
- Verify the pid sent in the UacMenuDto exists in the uac_menu table for the target environment.
- Re-query the menu tree via the menu list API and pick a valid parent menuId before saving.
- Check the uac_menu row with that id for lock/constraint issues and inspect DB logs for the failed update.
- Fix or clean up orphaned pid values with a SQL check: SELECT * FROM uac_menu p WHERE p.id = (child.pid).
Example fix
// before: trust the pid from the client
menu.setPid(dto.getPid());
insertMenu(menu);
// after: validate the parent exists first
UacMenu parent = uacMenuMapper.selectByPrimaryKey(dto.getPid());
if (parent == null) {
throw new UacBizException(ErrorCodeEnum.UAC10013003, dto.getPid());
}
menu.setPid(dto.getPid());
insertMenu(menu); Defensive patterns
Strategy: validation
Validate before calling
UacMenu parent = uacMenuMapper.selectByPrimaryKey(dto.getPid());
if (parent == null) {
throw new IllegalArgumentException("parent menu does not exist: " + dto.getPid());
} Type guard
boolean parentExists(Long pid) { return pid != null && uacMenuMapper.selectByPrimaryKey(pid) != null; } Try / catch
try {
uacMenuService.saveUacMenu(menuDto, loginAuthDto);
} catch (UacBizException e) {
if ("UAC10013002".equals(e.getCode())) { /* prompt: parent menu invalid/deleted */ }
throw e;
} Prevention
- Always load the parent menu in the UI from the live menu tree, not from cached ids.
- Validate pid against the DB before submitting the save request.
- Refresh the parent-menu dropdown after any concurrent menu deletions.
When it happens
Trigger: Calling saveUacMenu (POST /uac/menu/saveUacMenu) with a pid referencing a parent menu that does not exist in uac_menu, was deleted concurrently, or whose row cannot be updated (e.g. DB constraint/lock failure), so mapper.updateByPrimaryKeySelective returns 0.
Common situations: Frontend submits a stale pid after the parent menu was deleted by another admin; test data references a hardcoded parent menuId absent from the environment DB; data replication gaps between environments leave orphaned pid values.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/aa48a227e3831a52.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacMenuServiceImpl.java:149
@Override
public int saveUacMenu(UacMenu menu, LoginAuthDto loginAuthDto) {
Long pid = menu.getPid();
menu.setUpdateInfo(loginAuthDto);
UacMenu parentMenu = mapper.selectByPrimaryKey(pid);
if (PublicUtil.isEmpty(parentMenu)) {
throw new UacBizException(ErrorCodeEnum.UAC10013001, pid);
}
if (menu.isNew()) {
UacMenu updateMenu = new UacMenu();
menu.setLevel(parentMenu.getLevel() + 1);
updateMenu.setLeaf(MenuConstant.MENU_LEAF_NO);
updateMenu.setId(pid);
Long menuId = super.generateId();
menu.setId(menuId);
int result = mapper.updateByPrimaryKeySelective(updateMenu);
if (result < 1) {
throw new UacBizException(ErrorCodeEnum.UAC10013002, menuId);
}
menu.setStatus(UacMenuStatusEnum.ENABLE.getType());
menu.setCreatorId(loginAuthDto.getUserId());
menu.setCreator(loginAuthDto.getUserName());
menu.setLastOperatorId(loginAuthDto.getUserId());
menu.setLastOperator(loginAuthDto.getUserName());
// 新增的菜单是叶子节点
menu.setLeaf(MenuConstant.MENU_LEAF_YES);
return uacMenuMapper.insertSelective(menu);
} else {
return uacMenuMapper.updateByPrimaryKeySelective(menu);
}
}
@Override
public int deleteUacMenuById(Long id, LoginAuthDto loginAuthDto) {
Preconditions.checkArgument(id != null, "菜单id不能为空");View on GitHub (pinned to 781281a950)