Skip to content

fix(im): clarify messages-send dry-run chat membership#927

Open
xu91102 wants to merge 1 commit into
larksuite:mainfrom
xu91102:codex/im-dry-run-membership-warning
Open

fix(im): clarify messages-send dry-run chat membership#927
xu91102 wants to merge 1 commit into
larksuite:mainfrom
xu91102:codex/im-dry-run-membership-warning

Conversation

@xu91102
Copy link
Copy Markdown

@xu91102 xu91102 commented May 16, 2026

Summary

Clarify that im +messages-send --dry-run validates request shape only and does not prove the selected bot/user can send to the target chat.

Changes

  • Add a dry-run warning on chat-id sends explaining that chat membership is not verified.
  • Preserve existing dry-run descriptions such as media placeholder notes.
  • Add a dry-run shape regression test for the membership warning.

Test Plan

  • Targeted regression: go test ./shortcuts/im -run 'TestShortcutDryRunShapes/ImMessagesSend_dry_run_warns_chat_membership_is_not_verified' -count=1
  • Related dry-run shape tests: go test ./shortcuts/im -run 'TestShortcutDryRunShapes' -count=1
  • Related IM send tests: go test ./shortcuts/im -run 'TestImMessagesSend|TestShortcutDryRunShapes' -count=1
  • Format check: gofmt -l shortcuts/im/im_messages_send.go shortcuts/im/builders_test.go
  • Diff check: git diff --check -- shortcuts/im/im_messages_send.go shortcuts/im/builders_test.go
  • Full package test: go test ./shortcuts/im -count=1 was run locally on Windows but is blocked by existing media/path tests unrelated to this change (TestParseMediaDurationSuccess, TestNormalizeDownloadOutputPath, TestResolveIMResourceDownloadPath, TestValidateMediaFlagPath).

Related Issues

Summary by CodeRabbit

  • Bug Fixes
    • Dry-run for sending messages now displays a warning clarifying that bot/user chat membership is not verified during validation, though actual sends may still fail due to membership issues.

Review Change Stack

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

ImMessagesSend.DryRun now warns users that dry-run validates request shape only and does not verify bot/user membership in the target chat. A test sub-case validates the warning appears in output when using --chat-id with --text.

Changes

Dry-run membership verification warning

Layer / File(s) Summary
Add membership warning to ImMessagesSend dry-run
shortcuts/im/im_messages_send.go
When --chat-id is provided, dry-run appends a message clarifying that the dry-run validates request shape only and does not verify bot/user membership, since real sends may fail with "Bot/User can NOT be out of the chat".
Test membership warning in dry-run output
shortcuts/im/builders_test.go
New sub-test verifies that ImMessagesSend.DryRun with --chat-id and --text produces output containing the membership-not-verified warning strings.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A warning hops into the dry-run flow,
So users know what the test won't show—
No membership proof in the shape we check,
But a friendly message to save their neck! 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a dry-run warning to clarify chat membership is not verified in messages-send operations.
Description check ✅ Passed The PR description is comprehensive and mostly complete, covering summary, changes, detailed test plan, and related issues, though full package test is noted as blocked by unrelated issues.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #915: adding a dry-run warning that clarifies chat membership is not verified, with supporting regression test.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #915: dry-run warning text in im_messages_send.go and corresponding regression test in builders_test.go, with no extraneous modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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 May 16, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
shortcuts/im/builders_test.go (1)

732-742: ⚡ Quick win

Consider adding a negative test case for user-id sends.

The test correctly validates that the membership warning appears for --chat-id sends. For completeness, consider adding a companion test case that verifies the warning does NOT appear when using --user-id (since DM sends don't have chat membership semantics).

📋 Example negative test case
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, "does not verify that the selected bot/user is a member") {
		t.Fatalf("ImMessagesSend.DryRun() should not warn about membership for user-id sends: %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 negative test
alongside the existing "ImMessagesSend dry run warns chat membership is not
verified" that constructs a runtime via newTestRuntimeContext with "user-id"
(e.g., "ou_123") and "text", calls ImMessagesSend.DryRun(context.Background(),
runtime), marshals the result with mustMarshalDryRun, and asserts that the
membership warning string (e.g., "does not verify that the selected bot/user is
a member") is NOT present; reference ImMessagesSend.DryRun,
newTestRuntimeContext, and mustMarshalDryRun to locate where to add this test.
🤖 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 negative test alongside the existing
"ImMessagesSend dry run warns chat membership is not verified" that constructs a
runtime via newTestRuntimeContext with "user-id" (e.g., "ou_123") and "text",
calls ImMessagesSend.DryRun(context.Background(), runtime), marshals the result
with mustMarshalDryRun, and asserts that the membership warning string (e.g.,
"does not verify that the selected bot/user is a member") is NOT present;
reference ImMessagesSend.DryRun, newTestRuntimeContext, and mustMarshalDryRun to
locate where to add this test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 81a08a86-848f-4e83-9e1c-ca5083df277b

📥 Commits

Reviewing files that changed from the base of the PR and between 898e0ee and 2ba1f9e.

📒 Files selected for processing (2)
  • shortcuts/im/builders_test.go
  • shortcuts/im/im_messages_send.go

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.

Clarify that im messages-send --dry-run does not verify chat membership

2 participants