chore(im): clarify messages-send dry-run chat membership#1150
Conversation
📝 WalkthroughWalkthroughThe PR adds a membership verification warning to the ChangesChat membership warning for dry-run
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
shortcuts/im/builders_test.go (1)
732-742: ⚡ Quick winConsider adding a negative test case for
--user-idsends.The current test validates that the membership warning appears when
--chat-idis provided. Consider adding a complementary test case that verifies the warning does NOT appear when--user-idis used instead, to ensure the conditional behavior is correct in both branches.Example:
t.Run("ImMessagesSend dry run does not warn for user-id sends", func(t *testing.T) { runtime := newTestRuntimeContext(t, map[string]string{ "user-id": "ou_123", "text": "hello", }, nil) got := mustMarshalDryRun(t, ImMessagesSend.DryRun(context.Background(), runtime)) if strings.Contains(got, "membership in the target chat is not verified") { t.Fatalf("ImMessagesSend.DryRun() unexpected membership warning for --user-id: %s", got) } })🤖 Prompt for 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. In `@shortcuts/im/builders_test.go` around lines 732 - 742, Add a complementary negative test that ensures ImMessagesSend.DryRun does NOT emit the chat-membership warning when invoked with --user-id: create a new t.Run similar to the existing one but pass runtime := newTestRuntimeContext(t, map[string]string{"user-id":"ou_123","text":"hello"}, nil), call got := mustMarshalDryRun(t, ImMessagesSend.DryRun(context.Background(), runtime)), and assert that the returned string does NOT contain the membership warning text (fail the test if it does); place this alongside the existing test to cover the alternate branch.
🤖 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.
Nitpick comments:
In `@shortcuts/im/builders_test.go`:
- Around line 732-742: Add a complementary negative test that ensures
ImMessagesSend.DryRun does NOT emit the chat-membership warning when invoked
with --user-id: create a new t.Run similar to the existing one but pass runtime
:= newTestRuntimeContext(t,
map[string]string{"user-id":"ou_123","text":"hello"}, nil), call got :=
mustMarshalDryRun(t, ImMessagesSend.DryRun(context.Background(), runtime)), and
assert that the returned string does NOT contain the membership warning text
(fail the test if it does); place this alongside the existing test to cover the
alternate branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8c1798c0-fa45-46fa-9a99-0a57ad11c7bf
📒 Files selected for processing (2)
shortcuts/im/builders_test.goshortcuts/im/im_messages_send.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1150 +/- ##
=======================================
Coverage 68.63% 68.63%
=======================================
Files 625 625
Lines 58386 58389 +3
=======================================
+ Hits 40071 40076 +5
+ Misses 15027 15026 -1
+ Partials 3288 3287 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@0359c3f395eb0d1a46c6a16624b4f846d05cf67a🧩 Skill updatenpx skills add YangJunzhou-01/cli#fix-im-dry-run-chat-membership -y -g |
c4b5ea1 to
b2498ca
Compare
Change-Id: I8a3e765d2e9115b1b5470705ba58b84c91503580
b2498ca to
0359c3f
Compare
base on @xu91102
Summary
Clarify that
im +messages-send --dry-runvalidates request shape only and does not prove the selected bot/user can send to the target chat.Changes
Test Plan
go test ./shortcuts/im -run 'TestShortcutDryRunShapes/ImMessagesSend_dry_run_warns_chat_membership_is_not_verified' -count=1go test ./shortcuts/im -run 'TestShortcutDryRunShapes' -count=1go test ./shortcuts/im -run 'TestImMessagesSend|TestShortcutDryRunShapes' -count=1gofmt -l shortcuts/im/im_messages_send.go shortcuts/im/builders_test.gogit diff --check -- shortcuts/im/im_messages_send.go shortcuts/im/builders_test.goRelated Issues
Summary by CodeRabbit
Release Notes
--chat-idto clarify that dry-run validates request shape only and does not verify bot/user membership in the target chat.