{"record":{"id":"7dc44b6ce01caf2b","repo":"paascloud/paascloud-master","slug":"uac10013001","errorCode":"UAC10013001","errorMessage":"父菜单不存在,menuId=%s","messagePattern":"父菜单不存在,menuId=(.+?)","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacMenuServiceImpl.java","lineNumber":137,"sourceCode":"\tprivate List<MenuVo> getMenuVo(List<UacMenu> list) {\n\t\tList<MenuVo> menuVoList = Lists.newArrayList();\n\t\tfor (UacMenu uacMenu : list) {\n\t\t\tMenuVo menuVo = new MenuVo();\n\t\t\tBeanUtils.copyProperties(uacMenu, menuVo);\n\t\t\tmenuVo.setUrl(uacMenu.getUrl());\n\t\t\tmenuVo.setMenuName(uacMenu.getMenuName());\n\t\t\tmenuVoList.add(menuVo);\n\t\t}\n\t\treturn menuVoList;\n\t}\n\n\t@Override\n\tpublic int saveUacMenu(UacMenu menu, LoginAuthDto loginAuthDto) {\n\t\tLong pid = menu.getPid();\n\t\tmenu.setUpdateInfo(loginAuthDto);\n\t\tUacMenu parentMenu = mapper.selectByPrimaryKey(pid);\n\t\tif (PublicUtil.isEmpty(parentMenu)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10013001, pid);\n\t\t}\n\t\tif (menu.isNew()) {\n\n\t\t\tUacMenu updateMenu = new UacMenu();\n\t\t\tmenu.setLevel(parentMenu.getLevel() + 1);\n\t\t\tupdateMenu.setLeaf(MenuConstant.MENU_LEAF_NO);\n\t\t\tupdateMenu.setId(pid);\n\t\t\tLong menuId = super.generateId();\n\t\t\tmenu.setId(menuId);\n\t\t\tint result = mapper.updateByPrimaryKeySelective(updateMenu);\n\t\t\tif (result < 1) {\n\t\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10013002, menuId);\n\t\t\t}\n\n\t\t\tmenu.setStatus(UacMenuStatusEnum.ENABLE.getType());\n\t\t\tmenu.setCreatorId(loginAuthDto.getUserId());\n\t\t\tmenu.setCreator(loginAuthDto.getUserName());\n\t\t\tmenu.setLastOperatorId(loginAuthDto.getUserId());","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacMenuServiceImpl.java#L119-L155","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the parent menu is created first (parent-first insertion order in seeds/imports).","For top-level menus use the application's designated root-menu id as pid instead of 0/null.","Catch UacBizException UAC10013001 and prompt the user to reselect a valid parent from a freshly loaded menu tree."],"exampleFix":"// before\nUacMenu menu = new UacMenu();\nmenu.setPid(0L); // no root menu with id 0\nmenuService.saveUacMenu(menu, loginAuthDto);\n// after\nUacMenu root = menuService.getByMenuCode(MenuConstant.MENU_ROOT);\nUacMenu menu = new UacMenu();\nmenu.setPid(root.getId());\nmenuService.saveUacMenu(menu, loginAuthDto);","handlingStrategy":"validation","validationCode":"if (menu.getPid() == null || mapper.selectByPrimaryKey(menu.getPid()) == null) {\n    throw new BusinessException(\"parent menu \" + menu.getPid() + \" must exist before saving\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    menuService.saveUacMenu(menu, loginAuthDto);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10013001.getCode().equals(e.getCode())) {\n        return ResponseEntity.status(404).body(\"parent menu not found; reselect parent\");\n    }\n    throw e;\n}","preventionTips":["Seed/import menus parent-first so children never reference missing rows.","Use the designated root menu id for top-level entries instead of 0 or null.","Reload the menu tree before displaying the parent selector in the admin UI."],"tags":["resource-not-found","menu","java"],"backgroundTag":"resource-not-found","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}