ListDriveFilesAllPages 只以 next_page_token 是否为空作为终止条件,既不看 has_more,也没有重复 token 检测;同一文件里同一厂商的 ListWikiSpaces / ListWikiNodes 已在 #3645 修过,云盘这两条防护都漏了。 厂商返回 has_more=false 但残留非空 token,或返回重复的 page_token 时,循环会 拿同一个 token 反复请求同一页:定时同步任务会在 asynq 的 2h 超时前一直打 API (scheduler 侧 MaxRetry 5),资源选择器 GET /api/v1/datasources/:id/resources 永不返回,同时 all 每轮 append 不断增长。 按 #3645 的既有写法原样修复:listDriveFiles 透出 has_more,循环改为 if !hasMore || next == "" 才退出,并用 seenPageTokens 记录已用过的 token,重复即 返回 "feishu drive file pagination repeated page token" 错误。正常多页语义不变 (仍返回完整列表),只是不再空转。 测试:TestClientDriveListFilesPagination(drive 包)用 httptest 覆盖重复 token、 has_more=false 带残留 token、正常两页三种情况;注释掉守卫后该用例在 2s 内发出 4 万+ 次请求并以 context deadline exceeded 失败。 Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| confluence | ||
| dingtalk | ||
| feishu | ||
| gitlab | ||
| ima | ||
| notion | ||
| rss | ||
| yuque | ||