larksuite / larksuite/cli

--page-all 在第二页失败时仍返回成功结果

Open
#2,477 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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: 0CheckResponse 检查不出错误

例如第二页返回 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.