{"record":{"id":"d588c4c125d047d1","repo":"paascloud/paascloud-master","slug":"uac10012008","errorCode":"UAC10012008","errorMessage":"ErrorCodeEnum.UAC10012008","messagePattern":"ErrorCodeEnum\\.UAC10012008","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacUserServiceImpl.java","lineNumber":334,"sourceCode":"\n\t\t// 更新用户的操作时间\n\t\tfinal UacUser updateUser = new UacUser();\n\t\tupdateUser.setId(operUserId);\n\t\tupdateUser.setUpdateInfo(authResDto);\n\t\tuacUserMapper.updateUacUser(updateUser);\n\n\t\tif (PublicUtil.isEmpty(roleIdList)) {\n\t\t\t// 取消该角色的所有用户的绑定\n\t\t\tlogger.info(\"绑定角色成功\");\n\t\t\treturn;\n\t\t}\n\n\t\t// 绑定所选用户\n\t\tfor (Long roleId : roleIdList) {\n\t\t\tUacRole uacRole = uacRoleService.getRoleById(roleId);\n\t\t\tif (uacRole == null) {\n\t\t\t\tlogger.error(\"找不到绑定的角色. roleId={}\", roleId);\n\t\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012008, roleId);\n\t\t\t}\n\t\t\tuacRoleUserService.saveRoleUser(operUserId, roleId);\n\t\t}\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<UserMenuDto> queryUserMenuDtoData(LoginAuthDto authResDto) {\n\t\t// 返回的结果集\n\t\tList<UserMenuDto> list = Lists.newArrayList();\n\t\tList<MenuVo> menuList; // 该用户下所有的菜单集合\n\t\tLong userId = authResDto.getUserId();\n\t\tList<Long> ownerMenuIdList = Lists.newArrayList();\n\t\tPreconditions.checkArgument(!PubUtils.isNull(authResDto, userId), \"无访问权限\");\n\n\t\t// 查询该用户下所有的菜单Id集合\n\t\tUacUserMenu query = new UacUserMenu();\n\t\tquery.setUserId(userId);","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacUserServiceImpl.java#L316-L352","documentation":"UAC10012008 is thrown by UacUserServiceImpl.bindUserRoles when one of the role IDs submitted for binding to a user does not exist in the UAC role table. The service looks up each role via uacRoleService.getRoleById(roleId); a null result means the caller passed a stale, deleted, or fabricated roleId. The exception aborts the whole bind operation before any saveRoleUser for the offending id (though earlier roles in the loop may already be saved).","triggerScenarios":"Calling bindUserRoles(userId, roleIdList) where roleIdList contains a roleId that was deleted, belongs to another tenant, or was never created; passing client-supplied role ids without validating they exist.","commonSituations":"Stale frontend caches of role lists after an admin deleted a role; concurrent deletion of a role between listing and binding; clients fabricating or mis-typing role ids; data migration leaving orphaned role references.","solutions":["Refresh the role list from the server and ensure every roleId in the payload exists before calling bindUserRoles","Delete or correct the offending entry in roleIdList (the exception can be caught and its args inspected to find the bad roleId)","Verify the role exists in the DB: SELECT * FROM uac_role WHERE id = ?","If roles were deleted legitimately, propagate deletions to any UI/state that caches role ids"],"exampleFix":"// before\nuacRoleService.bindUserRoles(userId, roleIds); // roleIds from stale client cache\n// after\nList<Long> validIds = roleService.findAllIds();\nroleIds = roleIds.stream().filter(validIds::contains).collect(Collectors.toList());\nuacRoleService.bindUserRoles(userId, roleIds);","handlingStrategy":"validation","validationCode":"for (Long roleId : roleIdList) {\n    if (uacRoleService.getRoleById(roleId) == null) {\n        throw new IllegalArgumentException(\"role not found: \" + roleId);\n    }\n}","typeGuard":"boolean roleExists(Long roleId) { return uacRoleService.getRoleById(roleId) != null; }","tryCatchPattern":"try { uacUserService.bindUserRoles(userId, roleIds); } catch (UacBizException e) { if (\"UAC10012008\".equals(e.getCode())) { /* reload role list, notify invalid roleId */ } }","preventionTips":["Always load role ids from a fresh server-side list, never trust stale client caches","Validate all roleIds exist before invoking bindUserRoles","Handle role deletion by cascading removal from cached role selections"],"tags":["user-roles","not-found","validation"],"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"}