Skip to content

fix(feishu): paginate drive list/info to resolve files beyond first page#94030

Closed
xzh-icenter wants to merge 2 commits into
openclaw:mainfrom
xzh-icenter:fix/93928-drive-pagination-v2
Closed

fix(feishu): paginate drive list/info to resolve files beyond first page#94030
xzh-icenter wants to merge 2 commits into
openclaw:mainfrom
xzh-icenter:fix/93928-drive-pagination-v2

Conversation

@xzh-icenter

@xzh-icenter xzh-icenter commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: feishu_drive action: info returns File not found for files past page 1, and action: list cannot retrieve pages beyond the first — both ignore the has_more / next_page_token cursor the Lark API returns.
  • Why now: Any user with a Feishu drive folder containing more files than one API page (default 50) cannot access files beyond page 1 via the agent. This is a silent data-access bug.
  • What changed:
    • listFolder() now accepts page_size and page_token params and returns has_more in the response
    • getFileInfo() now paginates through all pages when searching for a file by token, instead of only checking the first page
    • list action schema now accepts page_size and page_token for cursor-based pagination
    • info action schema now accepts folder_token to narrow the search scope
  • What did NOT change: Comment pagination (list_comments, list_comment_replies) was already correct and untouched. No new dependencies added.
  • Outcome: Files past page 1 are now accessible. info finds files on any page. list can be called with page_token to fetch subsequent pages.
  • Reviewer focus: drive.ts changes to listFolder and getFileInfo functions, and drive-schema.ts schema additions.

Linked context

Closes #93928

Was this requested by a maintainer?

  • No, but the issue has clear reproduction steps and root cause analysis.

Root Cause

  • Root cause: getFileInfo() did a single drive.file.list call and only searched the first page results. listFolder() did not pass page_token to the Lark SDK and the schema exposed no cursor field.
  • Missing detection / guardrail: No pagination tests for list or info actions. The sibling list_comments and list_comment_replies paths already paginated correctly (see drive.ts:486-487, 519-520), making this the lone un-paginated lister in the plugin.

Real behavior proof

  • Behavior or issue addressed: feishu_drive info must find a file that lives past the first drive.file.list page instead of falsely reporting File not found. list must support cursor-based pagination.
  • Real environment tested: Node v22.14.0, branch fix/93928-drive-pagination-v2, real registerFeishuDriveTools runtime with Lark SDK drive.file.list mocked.
  • Exact steps or command run after this patch:
    node scripts/run-vitest.mjs test/vitest/vitest.extension-feishu.config.ts -- extensions/feishu/src/drive.test.ts
  • Evidence after fix:
    node scripts/run-vitest.mjs output:
    ✓ extension-feishu extensions/feishu/src/drive.test.ts (18 tests) 3340ms
    Test Files  1 passed (1)
         Tests  18 passed (18)
    
  • Observed result after fix: All 18 tests pass after running node scripts/run-vitest.mjs, including 3 new pagination tests (list with page_token, info finding file on page 3, info throwing File not found after exhausting all pages).
  • What was not tested: Not run against a live Feishu tenant; the proof drives the real plugin code path with the Lark drive.file.list response shape mocked rather than a live multi-page folder.
  • Proof limitations or environment constraints: Mock-based test — does not verify against actual Feishu API pagination behavior.

Tests and validation

Which commands did you run?

  • node scripts/run-vitest.mjs test/vitest/vitest.extension-feishu.config.ts -- extensions/feishu/src/drive.test.ts

What regression coverage was added or updated?

  • Added 3 new test cases:
    1. paginates list action returning requested page — verifies page_token is passed to SDK and has_more/next_page_token are returned
    2. paginates getFileInfo through multiple pages to find file — verifies 3-page pagination to find a file on page 3
    3. throws File not found after exhausting all pages — verifies error after single-page search with no match

What failed before this fix, if known?

  • info action threw File not found: <token> for any file past page 1
  • list action returned only page 1 with no way to fetch subsequent pages

- listFolder now accepts page_size and page_token params and returns has_more
- getFileInfo now paginates through all pages when searching for a file by token
- Added page_size and page_token to list action schema
- Added folder_token to info action schema for scoped search
- Added regression tests for pagination behavior

Fixes openclaw#93928
@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. size: M proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 17, 2026
@xzh-icenter

Copy link
Copy Markdown
Contributor Author

Superseded by a clean rebased PR.

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

Labels

channel: feishu Channel integration: feishu proof: supplied External PR includes structured after-fix real behavior proof. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu drive info falsely reports File not found for files past page 1 (list pagination already fixed in #101572)

1 participant