paascloud/paascloud-master · error · UacBizException

UAC10013001

UAC10013001

Error message

父菜单不存在,menuId=%s

What it means

saveUacMenu requires the menu's parent to exist. It loads parentMenu via mapper.selectByPrimaryKey(menu.getPid()); if absent it throws UacBizException(UAC10013001) "父菜单不存在,menuId=%s" (parent menu does not exist). The parent supplies the level and code context for the new menu, so it must resolve.

Solutions

  1. Ensure the parent menu is created first (parent-first insertion order in seeds/imports).
  2. For top-level menus use the application's designated root-menu id as pid instead of 0/null.
  3. Catch UacBizException UAC10013001 and prompt the user to reselect a valid parent from a freshly loaded menu tree.

Example fix

// before
UacMenu menu = new UacMenu();
menu.setPid(0L); // no root menu with id 0
menuService.saveUacMenu(menu, loginAuthDto);
// after
UacMenu root = menuService.getByMenuCode(MenuConstant.MENU_ROOT);
UacMenu menu = new UacMenu();
menu.setPid(root.getId());
menuService.saveUacMenu(menu, loginAuthDto);
Defensive patterns

Strategy: validation

Validate before calling

if (menu.getPid() == null || mapper.selectByPrimaryKey(menu.getPid()) == null) {
    throw new BusinessException("parent menu " + menu.getPid() + " must exist before saving");
}

Type guard

null

Try / catch

try {
    menuService.saveUacMenu(menu, loginAuthDto);
} catch (UacBizException e) {
    if (ErrorCodeEnum.UAC10013001.getCode().equals(e.getCode())) {
        return ResponseEntity.status(404).body("parent menu not found; reselect parent");
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling saveUacMenu with a pid that has no matching menu row — parent menu deleted, pid=0 or placeholder for what should be a root menu, or payload missing pid so a null/garbage id is looked up.

Common situations: Menu import scripts inserting children before parents; root menus incorrectly given a pid of 0 with no root row seeded; environments where menu tables diverge between dev and prod.

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/7dc44b6ce01caf2b. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacMenuServiceImpl.java:137

	private List<MenuVo> getMenuVo(List<UacMenu> list) {
		List<MenuVo> menuVoList = Lists.newArrayList();
		for (UacMenu uacMenu : list) {
			MenuVo menuVo = new MenuVo();
			BeanUtils.copyProperties(uacMenu, menuVo);
			menuVo.setUrl(uacMenu.getUrl());
			menuVo.setMenuName(uacMenu.getMenuName());
			menuVoList.add(menuVo);
		}
		return menuVoList;
	}

	@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());

View on GitHub (pinned to 781281a950)