{"record":{"id":"5c4eebee9db30d90","repo":"paascloud/paascloud-master","slug":"uac10015009","errorCode":"UAC10015009","errorMessage":"找不到上级组织, groupId=%s","messagePattern":"找不到上级组织, groupId=(.+?)","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java","lineNumber":346,"sourceCode":"\t\t\t\tlogger.error(\"找不到绑定的用户 userId={}\", userId);\n\t\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011024, userId);\n\t\t\t}\n\t\t\tUacGroupUser uacGroupUser = new UacGroupUser();\n\t\t\tuacGroupUser.setUserId(userId);\n\t\t\tuacGroupUser.setGroupId(groupId);\n\t\t\tuacGroupUserMapper.insertSelective(uacGroupUser);\n\t\t}\n\t}\n\n\t@Override\n\tpublic int saveUacGroup(UacGroup group, LoginAuthDto loginAuthDto) {\n\n\t\tint result;\n\t\tPreconditions.checkArgument(!StringUtils.isEmpty(group.getPid()), \"上级节点不能为空\");\n\n\t\tUacGroup parenGroup = uacGroupMapper.selectByPrimaryKey(group.getPid());\n\t\tif (PublicUtil.isEmpty(parenGroup)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10015009, group.getPid());\n\t\t}\n\t\tsetGroupAddress(group);\n\t\tgroup.setUpdateInfo(loginAuthDto);\n\n\t\tif (group.isNew()) {\n\t\t\tLong groupId = super.generateId();\n\t\t\tgroup.setId(groupId);\n\t\t\tgroup.setLevel(parenGroup.getLevel() + 1);\n\t\t\tresult = this.addUacGroup(group);\n\t\t} else {\n\t\t\tresult = this.editUacGroup(group);\n\t\t}\n\t\treturn result;\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic UacGroup getById(Long id) {","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java#L328-L364","documentation":"saveUacGroup requires the new/updated group to reference an existing parent. After asserting pid is non-empty, it loads the parent with uacGroupMapper.selectByPrimaryKey(group.getPid()); if absent it throws UacBizException(UAC10015009) \"找不到上级组织, groupId=%s\" (parent organization not found). This enforces the organization tree's referential integrity.","triggerScenarios":"Calling saveUacGroup with a pid that does not exist — parent deleted first, pid copied from another environment, or client sending pid=0/placeholder value that passes the non-empty check.","commonSituations":"Import/migration scripts creating children before parents; UI tree cache holding deleted nodes; seeding scripts assuming a root group id that wasn't created.","solutions":["Create/verify the parent organization exists before saving the child (parent-first insertion order).","Check the pid value — if creating a root-level group, use the correct root id convention rather than an arbitrary pid.","Catch UacBizException UAC10015009 and prompt the user to pick a valid parent node from a freshly loaded tree."],"exampleFix":"// before\nUacGroup child = new UacGroup();\nchild.setPid(12345L); // parent may not exist\nuacGroupService.saveUacGroup(child, loginAuthDto);\n// after\nUacGroup parent = uacGroupService.getById(parentId); // throws if missing\nUacGroup child = new UacGroup();\nchild.setPid(parent.getId());\nuacGroupService.saveUacGroup(child, loginAuthDto);","handlingStrategy":"validation","validationCode":"if (StringUtils.isEmpty(group.getPid()) || uacGroupMapper.selectByPrimaryKey(group.getPid()) == null) {\n    throw new BusinessException(\"parent group \" + group.getPid() + \" must exist before saving child\");\n}","typeGuard":"null","tryCatchPattern":"try {\n    uacGroupService.saveUacGroup(group, loginAuthDto);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10015009.getCode().equals(e.getCode())) {\n        return ResponseEntity.status(404).body(\"parent organization not found; pick a valid parent node\");\n    }\n    throw e;\n}","preventionTips":["Insert parent nodes before children in seeds, migrations, and imports.","Reload the org tree in the UI before showing the parent picker.","Reject save attempts when the selected parent id fails a fresh existence check."],"tags":["resource-not-found","hierarchy","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"}