--page-all 在第二页失败时仍返回成功结果
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 17.3k
- Forks
- 1.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 105
Description
我在看分页实现时发现,第一页成功后,如果后续页面请求失败,--page-all 会停止分页,但仍然把前面拿到的数据当成成功结果返回。
我用 fake transport 稳定复现了两种情况:
- 第二页返回网络错误:
PaginateAll的 error 仍然是nil - 第二页返回非零 API code:合并结果仍然保留第一页的
code: 0,CheckResponse检查不出错误
例如第二页返回 code: 999999 后,最终结果还是:
{
"code": "0",
"msg": "ok",
"data": {
"items": [{"id": "first"}],
"has_more": false
}
}
看起来原因是 paginateLoop 在后续页面失败时只执行了 break,而 mergePagedResults 又以第一页作为最终结果的基础。
期望后续页面失败时返回非零退出状态。流式输出可以保留已经写出的数据,但不能让调用方误以为结果完整。
复现版本:main@06798847
和 #590、#1859 的区别是:那两个是 page limit 截断,这个是后续请求失败后仍然返回成功。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the paginateLoop and mergePagedResults entry points, then inspect the existing fake-transport pagination tests and PaginateAll/CheckResponse handling. Reproduce both a network error and a non-zero API code on the second page. Done means later-page failures produce a non-zero result while streamed data may remain available, and regression tests cover both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100