{"record":{"id":"ef1aa99f98bdff94","repo":"flipped-aurora/gin-vue-admin","slug":"w-ef1aa9","errorCode":null,"errorMessage":"获取用户列表失败: %w","messagePattern":"获取用户列表失败: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/org_common.go","lineNumber":207,"sourceCode":"\treturn authority, nil\n}\n\n// scanUsersByIDs 按ID集合补全用户信息:上游 getUserList 不支持按ID过滤,翻页扫描至集齐或达页数上限,\n// 返回 命中映射 与 未解析ID 列表(行级可见范围由主服务侧 datascope 引擎决定)\nfunc scanUsersByIDs(ctx context.Context, ids []uint) (map[uint]system.SysUser, []uint, error) {\n\twant := make(map[uint]struct{}, len(ids))\n\tfor _, id := range ids {\n\t\twant[id] = struct{}{}\n\t}\n\tfound := make(map[uint]system.SysUser, len(ids))\n\n\tfor page := 1; page <= orgUserScanMaxPages && len(found) < len(want); page++ {\n\t\tresp, err := postUpstream[pageResultData[[]system.SysUser]](ctx, \"/user/getUserList\", map[string]any{\n\t\t\t\"page\":     page,\n\t\t\t\"pageSize\": orgUserScanPageSize,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"获取用户列表失败: %w\", err)\n\t\t}\n\t\tfor i := range resp.Data.List {\n\t\t\tuser := resp.Data.List[i]\n\t\t\tif _, ok := want[user.ID]; ok {\n\t\t\t\tfound[user.ID] = user\n\t\t\t}\n\t\t}\n\t\tif len(resp.Data.List) < orgUserScanPageSize {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tvar unresolved []uint\n\tfor _, id := range ids {\n\t\tif _, ok := found[id]; !ok {\n\t\t\tunresolved = append(unresolved, id)\n\t\t}\n\t}","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/org_common.go#L189-L225","documentation":"scanUsersByIDs pages through POST /user/getUserList (100 per page, up to 20 pages) looking for target user IDs, since upstream does not support filtering by ID. If any page request fails, the error is wrapped as 获取用户列表失败 and the whole scan aborts.","triggerScenarios":"Any org tool needing user lookups by ID (assign_user_org, findUserByID fallback) while a paginated POST /user/getUserList call fails: network error, token issue, upstream 4xx/5xx, or invalid response envelope.","commonSituations":"Upstream service briefly down or rate-limiting during multi-page scans; expired MCP upstream token; load balancer timeouts on large user tables.","solutions":["Check upstream /user/getUserList health and response codes manually","Retry the operation (transient network failures)","Verify the MCP upstream token is valid","Reduce load/rate or check upstream logs if 5xx occur on large pages"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// light pre-check: ensure upstream user list endpoint answers\nconst res = await fetch(baseUrl + '/user/getUserList', { method: 'POST', body: JSON.stringify({ page: 1, pageSize: 1 }) })\nif (!res.ok) throw new Error('user list endpoint unavailable')","typeGuard":null,"tryCatchPattern":"try {\n  await callMcpTool(tool, args)\n} catch (e) {\n  if (String(e.message).includes('获取用户列表失败')) {\n    // transient? retry with exponential backoff; else check token/connectivity via e.cause\n  }\n}","preventionTips":["Pass a username hint to avoid multi-page scans entirely","Keep tokens fresh; scans amplify the chance of hitting an expired-token failure mid-run","Monitor upstream latency; timeouts during long scans look like failures"],"tags":["network","upstream-api","mcp","pagination"],"backgroundTag":"upstream-request-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}