fix(im): handle messages-search page-limit int flag#446
fix(im): handle messages-search page-limit int flag#446YangJunzhou-01 wants to merge 1 commit intolarksuite:mainfrom
Conversation
Change-Id: Ic4876f4ca7f410a8fe3234e08e41b54ce26990d9
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request refactors the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR fixes Confidence Score: 5/5Safe to merge — the fix is minimal, targeted, and directly resolves a real validation regression with no side effects. All findings are P2 style suggestions. The core bug fix is correct: switching from Str to Int for an int-registered flag, with test helpers aligned accordingly. No P0/P1 issues found. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant CLI as CLI (cobra)
participant RT as RuntimeContext
participant BSR as buildMessagesSearchRequest
participant MPC as messagesSearchPaginationConfig
participant SM as searchMessages
CLI->>RT: --page-limit=2 (int flag)
RT->>BSR: runtime.Int("page-limit") → 2
BSR->>BSR: validate: 1 ≤ 2 ≤ 40 ✓
BSR-->>CLI: *messagesSearchRequest (no error)
CLI->>SM: Execute(req)
SM->>MPC: runtime.Int("page-limit") → 2
MPC-->>SM: autoPaginate=true, pageLimit=min(2,40)=2
SM-->>CLI: results (up to 2 pages)
Reviews (1): Last reviewed commit: "fix(im): handle messages-search page-lim..." | Re-trigger Greptile |
| for name := range stringFlags { | ||
| if name == "page-limit" { | ||
| cmd.Flags().Int(name, 20, "") | ||
| continue | ||
| } | ||
| cmd.Flags().String(name, "", "") |
There was a problem hiding this comment.
Int-flag semantics leaking into
stringFlags parameter
newTestRuntimeContext accepts stringFlags map[string]string, but now special-cases "page-limit" to register it as an int flag. This works, but any future int flag would need another hardcoded branch here. im_messages_search_execute_test.go took the cleaner approach of registering int flags outside the helper — consider adding an intFlags map[string]int parameter to newTestRuntimeContext for consistency and extensibility.
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@de80169563ef5e87ff67d1d02f86f96977afbf75🧩 Skill updatenpx skills add YangJunzhou-01/cli#fix/pagelimit -y -g |
Summary
Fix
lark-cli im +messages-search --page-limitincorrectly rejecting valid integer values such as--page-limit=2.page-limitis registered as an int flag, but the implementation was reading it viaruntime.Str("page-limit"). In real CLI execution this returned an empty value, causing validation to fail with:This PR updates
+messages-searchto readpage-limitviaruntime.Int("page-limit")and aligns the related test helpers with the real int flag registration.Scope
lark-cli im +messages-search--page-allwithout explicit--page-limitTest Plan
go test ./shortcuts/im -count=1Also verified locally that:
now succeeds and returns 2 results instead of failing validation.
Summary by CodeRabbit
--page-limitflag is properly processed as an integer with appropriate range validation, instead of relying on string parsing.