Skip to content

fix(im): +flag-list --page-all no longer silently truncates at default page-limit#1875

Open
jacob-qu wants to merge 1 commit into
larksuite:mainfrom
jacob-qu:fix/flag-list-page-all-truncation
Open

fix(im): +flag-list --page-all no longer silently truncates at default page-limit#1875
jacob-qu wants to merge 1 commit into
larksuite:mainfrom
jacob-qu:fix/flag-list-page-all-truncation

Conversation

@jacob-qu

@jacob-qu jacob-qu commented Jul 14, 2026

Copy link
Copy Markdown

Summary

im +flag-list --page-all was still capped by the default --page-limit of 20 and stopped there without any signal, even when has_more was true. Because the server returns canceled flags before active ones, active flags often live past page 20, so callers saw flag_items: [] and read it as "no flags" — misleading for both humans and AI agents. This aligns +flag-list with the pagination contract already used by im +chat-members-list and im +messages-search.

Changes

  • Allow --page-limit 0 to mean unlimited (validation now accepts 01000; 0 was previously rejected).
  • When the page limit is reached while more pages remain, emit a stderr warning pointing to --page-all --page-limit 0, instead of stopping silently.
  • Update the flag description to document 0 = unlimited.
  • Default behavior is unchanged (still 20 pages) — this only makes truncation visible and adds an unlimited escape hatch.

Test Plan

  • Unit tests pass (go test -race ./shortcuts/im/...)
  • Manual local verification confirms the lark-cli im +flag-list flow works as expected
    • --page-limit -1 / 1001 → typed validation error
    • --page-limit 0 → passes validation, dry-run shows the request
  • go vet, gofmt -l, and golangci-lint run --new-from-rev=origin/main (0 issues) all pass

New/updated tests pin the reversed validation contract (0 accepted, -1/1001 rejected), assert the truncation warning is emitted, and verify an unlimited scan reaches every page without falsely warning.

Related Issues

Summary by CodeRabbit

  • New Features

    • Added unlimited pagination support for the +flag-list shortcut by setting --page-limit=0.
    • Updated the flag description and validation guidance to clarify unlimited mode.
  • Bug Fixes

    • Flag listing now clearly reports when the configured page limit is reached while more results are available.
    • Invalid page-limit values continue to be rejected.

…t page-limit

`im +flag-list --page-all` was still capped by the default `--page-limit`
of 20 and stopped there without any signal, even when `has_more` was true.
Because the server returns canceled flags before active ones, active flags
often live past page 20, so callers saw `flag_items: []` and read it as
"no flags" — misleading for humans and AI agents alike.

Align flag-list with the existing pagination contract used by
`im +chat-members-list` and `im +messages-search`:

- Allow `--page-limit 0` to mean unlimited (validation now accepts 0-1000).
- When the page limit is reached while more pages remain, emit a stderr
  warning pointing to `--page-all --page-limit 0`, instead of stopping
  silently.
- Update the flag description to document `0 = unlimited`.

Tests pin the reversed validation contract (0 accepted, -1/1001 rejected),
assert the truncation warning is emitted, and verify an unlimited scan
reaches every page without falsely warning.

Closes larksuite#1859
@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18107137-a7aa-49c9-9acb-6ca06692077a

📥 Commits

Reviewing files that changed from the base of the PR and between 37d490a and 1c8defc.

📒 Files selected for processing (2)
  • shortcuts/im/im_flag_list.go
  • shortcuts/im/im_flag_test.go

📝 Walkthrough

Walkthrough

The +flag-list shortcut now accepts --page-limit=0 for unlimited pagination, updates validation messaging, reports bounded truncation, and adds tests for valid, invalid, bounded, and unlimited pagination behavior.

Changes

Flag pagination

Layer / File(s) Summary
Page-limit contract and validation
shortcuts/im/im_flag_list.go, shortcuts/im/im_flag_test.go
The --page-limit flag documents and accepts 0..1000, with zero representing unlimited pagination; negative and over-limit values remain invalid.
Pagination stopping behavior
shortcuts/im/im_flag_list.go, shortcuts/im/im_flag_test.go
Pagination uses explicit stopping conditions, warns when a configured limit truncates results, and continues until has_more=false when the limit is zero.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant executeListAllPages
  participant FlagsAPI
  CLI->>executeListAllPages: pass page-limit
  executeListAllPages->>FlagsAPI: request next flags page
  FlagsAPI-->>executeListAllPages: flags page and has_more
  executeListAllPages-->>CLI: results or page-limit warning
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: preventing silent truncation in +flag-list pagination.
Description check ✅ Passed The description follows the template with Summary, Changes, Test Plan, and Related Issues sections filled in.
Linked Issues check ✅ Passed The PR satisfies #1859 by making page-limit 0 unlimited and warning when pagination is truncated.
Out of Scope Changes check ✅ Passed The code changes stay focused on +flag-list pagination behavior and its tests, with no obvious unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@1c8defcb1c1f3d0ade486aed138ef3a2080e8b7f

🧩 Skill update

npx skills add jacob-qu/cli#fix/flag-list-page-all-truncation -y -g

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

Labels

domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

im +flag-list: 默认分页截断导致有效标记数量误报为 0,无法快速读取实时 Flagged 数量

2 participants