{"record":{"id":"4642bdd80a9f6ae6","repo":"paascloud/paascloud-master","slug":"uac10013009","errorCode":"UAC10013009","errorMessage":"ErrorCodeEnum.UAC10013009","messagePattern":"ErrorCodeEnum\\.UAC10013009","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"warning","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java","lineNumber":270,"sourceCode":"\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic BindAuthVo getActionTreeByRoleId(Long roleId) {\n\t\tBindAuthVo bindAuthVo = new BindAuthVo();\n\t\tif (roleId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\n\t\tUacRole roleById = this.getRoleById(roleId);\n\t\tif (roleById == null) {\n\t\t\tlogger.error(\"找不到角色信息 roleId={}\", roleId);\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012005, roleId);\n\t\t}\n\n\t\tList<UacMenu> uacMenus = uacMenuService.listMenuListByRoleId(roleId);\n\t\tif (PublicUtil.isEmpty(uacMenus)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10013009);\n\t\t}\n\t\t// 查询所有的权限信息\n\t\tList<UacAction> uacActions = uacActionService.listActionList(uacMenus);\n\t\t// 合并菜单和按钮权限 递归生成树结构\n\n\t\tList<MenuVo> menuVoList = this.getAuthList(uacMenus, uacActions);\n\n\t\tList<MenuVo> tree = TreeUtil.getChildMenuVos(menuVoList, 0L);\n\n\t\t// 获取所有绑定的菜单和按钮权限Id集合\n\t\tList<Long> checkedAuthList = uacActionService.getCheckedActionList(roleId);\n\n\t\tbindAuthVo.setAuthTree(tree);\n\t\tbindAuthVo.setCheckedAuthList(checkedAuthList);\n\n\t\treturn bindAuthVo;\n\t}\n","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java#L252-L288","documentation":"getActionTreeByRoleId throws UacBizException UAC10013009 when uacMenuService.listMenuListByRoleId(roleId) returns an empty list, meaning the role has no assigned menus, so no action tree can be built. It signals '该角色未分配菜单' (role has no menus assigned) semantics.","triggerScenarios":"Requesting the action tree for a freshly created role that has not yet been granted any menus, or after all its menus were unassigned.","commonSituations":"Opening the permission configuration page for a brand-new role; a cleanup job or earlier edit removed the role's menu grants.","solutions":["Assign menus to the role first (uacRoleMenuService / role-menu binding API) before requesting its action tree","Treat UAC10013009 as 'empty tree' and show an empty state in the UI instead of an error","Pre-seed default menu grants when creating roles programmatically"],"exampleFix":"// before\nBindAuthVo vo = uacRoleService.getActionTreeByRoleId(roleId);\n// after\ntry {\n    vo = uacRoleService.getActionTreeByRoleId(roleId);\n} catch (UacBizException e) {\n    if (\"UAC10013009\".equals(e.getCode())) { vo = BindAuthVo.empty(); } else { throw e; }\n}","handlingStrategy":"try-catch","validationCode":"List<UacMenu> menus = uacMenuService.listMenuListByRoleId(roleId);\nif (PublicUtil.isEmpty(menus)) { /* show empty tree instead of calling */ }","typeGuard":"boolean hasMenus = !uacMenuService.listMenuListByRoleId(roleId).isEmpty();","tryCatchPattern":"try { vo = service.getActionTreeByRoleId(roleId); } catch (UacBizException e) { if (\"UAC10013009\".equals(e.getCode())) { vo = BindAuthVo.empty(); } else { throw e; } }","preventionTips":["Assign default menus when creating roles","Render an empty state for roles without menus instead of treating it as an error"],"tags":["empty-result-set","java","menu"],"backgroundTag":"empty-result-set","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"}