Skip to content

fix(im): warn when flag pagination is truncated#1906

Open
zhumiaoxin wants to merge 1 commit into
larksuite:mainfrom
zhumiaoxin:fix/im-flag-list-pagination-warning
Open

fix(im): warn when flag pagination is truncated#1906
zhumiaoxin wants to merge 1 commit into
larksuite:mainfrom
zhumiaoxin:fix/im-flag-list-pagination-warning

Conversation

@zhumiaoxin

@zhumiaoxin zhumiaoxin commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes the silent partial-result behavior in im +flag-list --page-all when the configured page limit is reached with has_more=true. The default remains 20 pages, the hard maximum remains 1000, and the JSON schema and exit code stay unchanged.

Changes

  • Emit an actionable stderr warning only when pagination actually stops at --page-limit; direct callers to the continuation token in stdout without copying the opaque token into logs.
  • Clarify in command help and the lark-im skill that 20 is the default cap, 1000 is the hard maximum, and has_more=true means the result is incomplete.
  • Add regression coverage for bounded truncation, natural completion, repeated tokens, unchanged JSON output, non-disclosure of continuation tokens, and the supported maximum page limit.

Test Plan

  • make unit-test
  • go vet ./...
  • gofmt -l . (no output)
  • go mod tidy (no go.mod / go.sum diff)
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=origin/main (0 issues)

Related Issues

@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 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

--page-all pagination now stops at --page-limit, warns when results remain incomplete, preserves continuation metadata, and documents how to resume pagination and interpret incomplete results.

Changes

Flag-list pagination

Layer / File(s) Summary
Pagination limit contract
shortcuts/im/im_flag_list.go
Flag metadata describes the default and configurable page limits, while executeListAllPages warns and stops when more pages remain beyond the configured limit.
Pagination behavior validation
shortcuts/im/im_flag_test.go
Tests cover natural completion, page-limit warnings, continuation fields, token privacy, schema compatibility, and repeated tokens.
Pagination documentation
skills/lark-im/SKILL.md, skills/lark-im/references/lark-im-flag-list.md
Documentation explains bounded pagination, incomplete results, continuation via page_token, sorting guidance, limits, and deleted-item ordering.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as executeListAllPages
  participant API as IM flags API
  participant Stdout as stdout
  participant Stderr as stderr
  CLI->>API: Request page with page_token
  API-->>CLI: Return flag_items, has_more, page_token
  CLI->>Stderr: Warn when page limit is reached with has_more=true
  CLI->>Stdout: Return pagination metadata and continuation token
Loading

Possibly related PRs

  • larksuite/cli#770: Refines the same +flag-list pagination stop and warning behavior.

Suggested labels: domain/im, size/M, feature

Suggested reviewers: yangjunzhou-01, liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address #1859 by warning on page-limit truncation while preserving bounded pagination, schema, and exit code.
Out of Scope Changes check ✅ Passed The code, tests, and docs all align with the stated pagination-truncation fix and related guidance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: warning when --page-all pagination is truncated.
Description check ✅ Passed The description follows the template and includes summary, changes, test plan, and related issue.
✨ 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

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add zhumiaoxin/cli#fix/im-flag-list-pagination-warning -y -g

@zhumiaoxin
zhumiaoxin force-pushed the fix/im-flag-list-pagination-warning branch from bfd65a6 to 982bb71 Compare July 15, 2026 14:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/cli_e2e/im/flag_workflow_test.go`:
- Around line 243-245: Update the pagination assertion in the relevant CLI
workflow test to first require that data.has_more exists, then branch on its
value: require the page-limit warning when true and assert stderr does not
contain that warning when false. Cover both pagination-warning outcomes instead
of allowing a missing or false field to pass silently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bd0059c6-940f-4455-a4d7-1475ed522332

📥 Commits

Reviewing files that changed from the base of the PR and between bfd65a6 and 982bb71.

📒 Files selected for processing (5)
  • shortcuts/im/im_flag_list.go
  • shortcuts/im/im_flag_test.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-flag-list.md
  • tests/cli_e2e/im/flag_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • skills/lark-im/SKILL.md
  • shortcuts/im/im_flag_list.go
  • shortcuts/im/im_flag_test.go

Comment thread tests/cli_e2e/im/flag_workflow_test.go
@zhumiaoxin
zhumiaoxin force-pushed the fix/im-flag-list-pagination-warning branch 2 times, most recently from d627de4 to f0a791f Compare July 15, 2026 15:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/lark-im/references/lark-im-flag-list.md`:
- Around line 9-11: Update the pagination guidance in the Lark IM flag list
documentation to distinguish the last fetched page from the API’s final page:
treat the last item as authoritative only when pagination ends with
has_more=false. When the page limit is reached while has_more=true, describe
that item only as the newest observed item and require continuing pagination or
resuming with page_token for authoritative results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fb48a5a9-6c7a-46e9-81f2-c530d4d9187e

📥 Commits

Reviewing files that changed from the base of the PR and between d627de4 and f0a791f.

📒 Files selected for processing (4)
  • shortcuts/im/im_flag_list.go
  • shortcuts/im/im_flag_test.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-flag-list.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • skills/lark-im/SKILL.md
  • shortcuts/im/im_flag_list.go
  • shortcuts/im/im_flag_test.go

Comment thread skills/lark-im/references/lark-im-flag-list.md Outdated
@zhumiaoxin
zhumiaoxin force-pushed the fix/im-flag-list-pagination-warning branch from f0a791f to d367b7d Compare July 15, 2026 15:58
@zhumiaoxin
zhumiaoxin force-pushed the fix/im-flag-list-pagination-warning branch from d367b7d to ff5b7b2 Compare July 17, 2026 08:00
@github-actions

Copy link
Copy Markdown

PR Quality Summary

CI did not complete successfully. Use the failed check links below to decide whether this PR needs a code change or a rerun.

Failed checks

  • deterministic-gate — failure — details
  • results — failure — details

deterministic-gate

  • example_dry_runskills/lark-im/references/lark-im-flag-list.md:26 — example dry-run output is not valid dry-run JSON: dry-run output does not contain JSON — Action: ensure --dry-run prints a JSON request preview
  • example_dry_runskills/lark-im/references/lark-im-flag-list.md:29 — example dry-run exited with code 1: { "ok": false, "identity": "user", "error": { "type": "api", "subtype": "unknown", "message": "jq error: cannot iterate over: null" } } — Action: update the example so it can run locally with --dry-run, or mark placeholders explicitly

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 数量

1 participant