Skip to content

fix(im): warn on stderr when +messages-search stops at the page limit - #2930

Open
vegerot wants to merge 1 commit into
larksuite:mainfrom
vegerot:fix/messages-search-page-limit-warning
Open

vegerot wants to merge 1 commit into
larksuite:mainfrom
vegerot:fix/messages-search-page-limit-warning

Conversation

@vegerot

@vegerot vegerot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

im +messages-search --page-all stops after 40 pages, and in JSON output (the default) nothing says so: the warning lived only in the pretty-format renderer. This PR prints the warning on stderr in every --format, in the same form that +flag-list and +chat-members-list already use.

Changes

  • searchMessages writes [pagination] reached page limit (N) while has_more=true; result is incomplete. … to stderr at the point where the page limit stops the loop.
  • Remove the pretty-only stdout warning. It duplicated the new one, and its advice (use --page-limit, --page-all …) was wrong when --page-all had already used the maximum of 40 pages.
  • searchMessages no longer returns truncatedByLimit and pageLimit; nothing reads them now.
  • The stdout schema is unchanged (messages, total, has_more, page_token).
  • skills/lark-im/references/lark-im-messages-search.md: say that the page cap produces a stderr warning.

Test Plan

  • Unit tests pass: go test -count=1 ./shortcuts/im/. TestImMessagesSearchExecuteAutoPaginationBatches now asserts the stderr warning and that stdout does not carry it. The test failed before the fix.

  • Manual local verification confirms the lark-cli im +messages-search flow works as expected:

    $ lark-cli im +messages-search --as user --sender-type bot --start <7 days ago> \
        --page-size 1 --page-limit 2 --no-reactions >out.json
    [pagination] reached page limit (2) while has_more=true; result is incomplete. Raise --page-limit (max 40) or resume with --page-token and the page_token returned in stdout.
    $ jq --compact-output '.data | keys' out.json
    ["has_more","messages","page_token","total"]
    

    A search that ends naturally (has_more: false) prints nothing on stderr.

  • go build ./..., go vet ./shortcuts/im/, gofmt -l, golangci-lint v2.1.6 run --new-from-rev=c5fbf1a5 ./shortcuts/im/... (0 issues), go run -C lint . --changed-from c5fbf1a5 .., node scripts/skill-format-check/index.js.

Related Issues

Co-Authored-By: Claude Fable 5.2 noreply@anthropic.com

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Page-limit warnings during message searches now appear on stderr instead of formatted results. Search output remains free of the warning, while stderr includes guidance for continuing through remaining results.
  • Documentation
    • Clarified that reaching the automatic pagination limit produces a warning in every output format, and that results may remain incomplete until all pages are fetched.

`+messages-search --page-all` stops after 40 pages. The warning about
that was printed only by the pretty-format renderer, so the default
JSON output gave no sign that the result was incomplete apart from
`has_more: true`.

Print the warning from the pagination loop to stderr, in the same
`[pagination] reached page limit` form that `+flag-list` and
`+chat-members-list` use. The stdout schema does not change. The old
stdout warning is removed; it also suggested `--page-all`, which cannot
continue a search that already used the maximum.

Fixes larksuite#2929

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 23:30
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Message search now reports when auto-pagination reaches its page limit with more results available. The warning goes to stderr in every output format, and the formatted results no longer include a page-limit warning.

Changes: Message search pagination

Layer / File(s) Summary
Page-limit warning and output handling
shortcuts/im/im_messages_search.go, shortcuts/im/im_messages_search_execute_test.go, skills/lark-im/references/lark-im-messages-search.md
searchMessages writes an incomplete-results warning to stderr when the page limit is reached and has_more is true. It returns results and pagination metadata without truncation status or the page limit. Tests verify the warning is absent from stdout and present on stderr. The reference documents this behavior and states that results remain incomplete until has_more is false.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: yangjunzhou-01, arnold9672, liangshuo-1

Merge Risk: Minimal · up to a660d

The change reports page-limit truncation on stderr in every output format and leaves the JSON stdout schema unchanged. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: a stderr warning from +messages-search when auto-pagination stops at the page limit. It matches the main change in the summary and objectives. The fix(im) prefix is a conve…
Description check Passed The description follows the template sections (Summary, Changes, Test Plan, Related Issues). It explains the motivation, lists the code and doc changes, and reports tests and manual verification. Rela…
Linked Issues check Passed [#2929] requires a stderr page-limit warning in every output format when +messages-search stops at the page limit with more results available, and an unchanged stdout schema. At head, shortcuts/im/im_…
Out of Scope Changes check Passed The changes stay within #2929. They are: (1) the new stderr warning in searchMessages; (2) removal of the pretty-only stdout warning in Execute, which duplicated the new warning and gave advice that w…
Full details: Title check

Explanation

The title names the change: a stderr warning from +messages-search when auto-pagination stops at the page limit. It matches the main change in the summary and objectives. The fix(im) prefix is a conventional-commit style scope and does not hurt clarity.

Full details: Description check

Explanation

The description follows the template sections (Summary, Changes, Test Plan, Related Issues). It explains the motivation, lists the code and doc changes, and reports tests and manual verification. Related Issues links #2929 and references the #1859 fix. The template's Test Plan items are checked, and the author adds extra verification detail. The description is complete for this change.

Full details: Linked Issues check

Explanation

[#2929] requires a stderr page-limit warning in every output format when +messages-search stops at the page limit with more results available, and an unchanged stdout schema. At head, shortcuts/im/im_messages_search.go, searchMessages, emits the line [pagination] reached page limit (N) while has_more=true; result is incomplete. ... to runtime.IO().ErrOut when autoPaginate is set, lastHasMore is true, a page token exists, and pageCount >= pageLimit. This check runs before the loop continues, so it applies regardless of --format. The Execute function no longer has a format-specific page-limit warning; the stdout maps still contain messages, total, has_more, and page_token, with the existing optional notice. The warning text matches the form the issue cites for +flag-list (#1859). The test file change (TestImMessagesSearchExecuteAutoPaginationBatches) and the skill doc change were not read as diffs in this review; their support comes from the PR description and the change summary. The head file read confirmed the implementation. The #2929 requirements are met by the code at head. The task +get-my-tasks pattern mentioned in the issue is context only and is not required here.

Full details: Out of Scope Changes check

Explanation

The changes stay within #2929. They are: (1) the new stderr warning in searchMessages; (2) removal of the pretty-only stdout warning in Execute, which duplicated the new warning and gave advice that was wrong at the 40-page maximum; (3) removal of the unused truncatedByLimit and pageLimit return values, which only the removed warning used; (4) a test update that checks the stderr warning and checks that stdout does not contain it; (5) a documentation line in lark-im-messages-search.md describing the new stderr warning. Each item directly supports the requested behavior. No unrelated changes appear in the reviewed head file or in the change summary. The get-my-tasks code is not changed by this PR.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df9b011c-c738-4730-b912-23df55add0e1
Commits

Reviewing files that changed from the base of the PR and between c5fbf1a and a660d52.

Files selected for processing: 3

  • shortcuts/im/im_messages_search.go
  • shortcuts/im/im_messages_search_execute_test.go
  • skills/lark-im/references/lark-im-messages-search.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@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 Nov 24, 2026

Copilot AI 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.

🟡 Changes recommended

A test in shortcuts/im/im_messages_search_execute_test.go uses an overly broad stdout substring assertion ("page limit") that risks false positives, so the assertion should be tightened to the specific pagination marker before approval.

1 open issue
What changed in this PR

Make im +messages-search emit a pagination truncation warning to stderr across all output formats so JSON/machine-readable stdout remains unchanged but users are informed when auto-pagination stops at the hard page cap.

Changes:

  • Print [pagination] reached page limit ... result is incomplete to stderr when auto-pagination stops while has_more=true.
  • Remove the pretty-only stdout warning and simplify searchMessages return values accordingly.
  • Update unit tests and the skill reference documentation to reflect the new stderr warning behavior.
File Description
skills/​lark-im/​references/​lark-im-messages-search.md Updates the command reference to document that hitting the page cap produces a stderr pagination warning while keeping stdout schema unchanged.
shortcuts/​im/​im_messages_search.go Moves the page-limit truncation warning into the search/pagination loop and emits it on stderr for all formats while removing the previous pretty-only warning plumbing.
shortcuts/​im/​im_messages_search_execute_test.go Adjusts the execution test to assert the truncation warning appears on stderr and does not contaminate stdout output.

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

Comment on lines +159 to +161
if strings.Contains(output, "page limit") {
t.Fatalf("stdout = %q, must not carry the page limit warning", output)
}

This branch has not been deployed

No deployments
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.

[Bug] im +messages-search: --page-all stops at the page limit with no warning in JSON output

2 participants