Skip to content

fix(drive): stop file iterator on empty page token - #226

Open
ZYZ666-RGB wants to merge 1 commit into
larksuite:v3_mainfrom
ZYZ666-RGB:fix/empty-page-token-iterator
Open

fix(drive): stop file iterator on empty page token#226
ZYZ666-RGB wants to merge 1 commit into
larksuite:v3_mainfrom
ZYZ666-RGB:fix/empty-page-token-iterator

Conversation

@ZYZ666-RGB

@ZYZ666-RGB ZYZ666-RGB commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • treat both nil and empty next-page tokens as terminal in ListFileIterator
  • preserve pagination when the API returns a non-empty next-page token
  • add regression tests verifying that an empty token does not issue another request

Problem

ListFileIterator.Next() currently stops only when NextPageToken is nil.

The Drive API may return a non-nil pointer containing an empty string on the final page. In that case, the iterator sends another request with an empty page_token, which may repeat pagination until the caller's context times out.

Testing

Added focused unit tests covering:

  • empty next-page token terminates iteration without another request
  • non-empty next-page token is forwarded and continues iteration
  • nil next-page token terminates after the final page
GOARCH=amd64 go test ./service/drive/v1 -run TestListFileIterator -count=1
ok github.com/larksuite/oapi-sdk-go/v3/service/drive/v1

Fixes #220

@CLAassistant

CLAassistant commented Jul 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ZYZ666-RGB

Copy link
Copy Markdown
Author

Hi maintainers, just following up on this PR. The CLA is complete, the focused iterator tests pass, and the change fixes #220. Please let me know if any changes or additional tests are needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

page_token判断失效导致循环分页查询

2 participants