{"record":{"id":"0fa40b0cddf6deb1","repo":"paascloud/paascloud-master","slug":"uac10011024","errorCode":"UAC10011024","errorMessage":"找不到绑定的用户, userId=%","messagePattern":"找不到绑定的用户, userId=%","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":329,"sourceCode":"\t\t// 1. 先取消对该角色的用户绑定(不包含超级管理员用户)\n\t\tList<UacGroupUser> groupUsers = uacGroupUserMapper.listByGroupId(groupId);\n\n\t\tif (PublicUtil.isNotEmpty(groupUsers)) {\n\t\t\tuacGroupUserMapper.deleteExcludeSuperMng(groupId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);\n\t\t}\n\n\t\tif (PublicUtil.isEmpty(userIdList)) {\n\t\t\t// 取消该角色的所有用户的绑定\n\t\t\tlogger.info(\"取消绑定所有非超级管理员用户成功\");\n\t\t\treturn;\n\t\t}\n\n\t\t// 绑定所选用户\n\t\tfor (Long userId : userIdList) {\n\t\t\tUacUser uacUser = uacUserService.queryByUserId(userId);\n\t\t\tif (PublicUtil.isEmpty(uacUser)) {\n\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}","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacGroupServiceImpl.java#L311-L347","documentation":"While binding each selected user, bindUacUser4Group queries the user via uacUserService.queryByUserId(userId). If a user id does not resolve to an existing UacUser it throws UacBizException(UAC10011024) \"找不到绑定的用户, userId=%\" (bound user not found). Note the loop means earlier inserts already succeeded, so the transaction context matters.","triggerScenarios":"userIdList containing a stale or foreign user id — user deleted concurrently, id copied from another environment, or client sending user codes instead of numeric ids.","commonSituations":"Race where the user account is deleted between listing and binding; test fixtures referencing non-seeded users; environments (dev/staging) with divergent user tables.","solutions":["Validate all userIds exist (batch query) before invoking bindUacUser4Group so nothing is half-bound.","Remove stale ids from userIdList and retry; refresh the user list from the server.","Catch UacBizException UAC10011024; if the service is not transactional, clean up already-inserted UacGroupUser rows before retrying."],"exampleFix":"// before\nreq.setUserIdList(userIds); // may contain deleted users\nuacGroupService.bindUacUser4Group(req, loginAuthDto);\n// after\nList<UacUser> found = uacUserService.listByUserIds(userIds);\nList<Long> validIds = found.stream().map(UacUser::getId).collect(Collectors.toList());\nif (validIds.size() != userIds.size()) {\n    throw new BusinessException(\"some users no longer exist; refresh selection\");\n}\nreq.setUserIdList(validIds);\nuacGroupService.bindUacUser4Group(req, loginAuthDto);","handlingStrategy":"validation","validationCode":"Map<Long, UacUser> found = uacUserService.listByUserIds(req.getUserIdList()).stream()\n    .collect(Collectors.toMap(UacUser::getId, u -> u));\nList<Long> missing = req.getUserIdList().stream().filter(id -> !found.containsKey(id)).collect(Collectors.toList());\nif (!missing.isEmpty()) {\n    throw new BusinessException(\"users not found: \" + missing);\n}","typeGuard":"null","tryCatchPattern":"try {\n    uacGroupService.bindUacUser4Group(req, loginAuthDto);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10011024.getCode().equals(e.getCode())) {\n        return ResponseEntity.status(404).body(\"a selected user no longer exists; refresh the user list\");\n    }\n    throw e;\n}","preventionTips":["Batch-verify all user ids before binding instead of relying on the per-row check.","Refresh user lists from the server immediately before batch operations.","Run the bind inside a transaction so partial inserts roll back on failure."],"tags":["user-not-found","database","java"],"backgroundTag":"user-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"}