fix: support safe file input for IM message bodies#1892
Conversation
|
ZSY seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
📝 WalkthroughWalkthroughIM message send and reply flags now explicitly accept file and stdin inputs. Documentation adds Markdown file and pipeline examples, and an end-to-end dry-run test verifies that shell-like Markdown content remains unchanged. ChangesIM message input support
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
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/message_markdown_input_dryrun_test.go`:
- Line 44: Update the content extraction in the dry-run test to read the request
preview from the `data.api` envelope by using `clie2e.DryRunGet(result.Stdout,
"api.0.body.content")` instead of querying `data.request.body.content` directly.
🪄 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: 6256cda2-0472-4345-af4f-96fb73224aa5
📒 Files selected for processing (6)
shortcuts/im/helpers_test.goshortcuts/im/im_messages_reply.goshortcuts/im/im_messages_send.goskills/lark-im/references/lark-im-messages-reply.mdskills/lark-im/references/lark-im-messages-send.mdtests/cli_e2e/im/message_markdown_input_dryrun_test.go
| require.NoError(t, err) | ||
| result.AssertExitCode(t, 0) | ||
|
|
||
| content := gjson.Get(result.Stdout, "data.request.body.content").String() |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Find existing dry-run gjson.Get calls to confirm the expected path structure.
rg -n 'gjson\.Get.*body' tests/cli_e2e/ -C 1Repository: larksuite/cli
Length of output: 8574
🏁 Script executed:
#!/bin/bash
sed -n '1,140p' tests/cli_e2e/im/message_markdown_input_dryrun_test.go
printf '\n---\n'
rg -n 'DryRunData|request\.body|data\.request|body\.content|projection\.body|api\.[0-9]+\.body' tests/cli_e2e -SRepository: larksuite/cli
Length of output: 31785
🏁 Script executed:
#!/bin/bash
rg -n '"data\.request\.body\.content"|data\.request\.body|request\.body\.content|DryRunGet\(|DryRunData\(' . -SRepository: larksuite/cli
Length of output: 50369
🏁 Script executed:
#!/bin/bash
sed -n '1,140p' tests/cli_e2e/core.go
printf '\n---\n'
rg -n 'dry[- ]run|request\.body|body\.content|gjson|Stdout|DryRun' im tests/cli_e2e/im -SRepository: larksuite/cli
Length of output: 24933
🏁 Script executed:
#!/bin/bash
rg -n 'messages-send|--markdown|request\.body\.content|dry[- ]run.*request|request\.body' . -S --glob '!tests/cli_e2e/im/message_markdown_input_dryrun_test.go'Repository: larksuite/cli
Length of output: 46524
🏁 Script executed:
#!/bin/bash
sed -n '1,180p' shortcuts/im/im_messages_send.go
printf '\n---\n'
sed -n '900,1045p' shortcuts/im/helpers.go
printf '\n---\n'
sed -n '240,340p' internal/cmdutil/dryrun.goRepository: larksuite/cli
Length of output: 15184
🏁 Script executed:
#!/bin/bash
rg -n 'type DryRunAPI|func \(.*DryRunAPI.*Format|func NewDryRunAPI|type dryRun|WriteSuccessEnvelope|SuccessEnvelope' internal shortcuts -SRepository: larksuite/cli
Length of output: 4623
🏁 Script executed:
#!/bin/bash
sed -n '1,240p' internal/cmdutil/dryrun.go
printf '\n---\n'
sed -n '1,120p' shortcuts/apps/dryrun_test.go
printf '\n---\n'
sed -n '1,220p' internal/output/envelope_success.goRepository: larksuite/cli
Length of output: 8992
Read the body from data.api.0.body.content. The dry-run envelope stores request previews under data.api[...], so data.request.body.content is empty here. Use clie2e.DryRunGet(result.Stdout, "api.0.body.content") instead.
🤖 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 `@tests/cli_e2e/im/message_markdown_input_dryrun_test.go` at line 44, Update
the content extraction in the dry-run test to read the request preview from the
`data.api` envelope by using `clie2e.DryRunGet(result.Stdout,
"api.0.body.content")` instead of querying `data.request.body.content` directly.
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@0cd6b4f4a5a67ec401875141c90693aeb476e8d5🧩 Skill updatenpx skills add SiyiZhu1/cli#agent/im-message-file-input -y -g |
What changed
im +messages-sendandim +messages-replybody flags (--text,--markdown, and--content) to read from a cwd-relative@fileor stdin (-)Why
Long or agent-generated message bodies are currently passed only as inline command-line strings. Markdown code fences,
$()expressions, dollar signs, quotes, and backticks can therefore be interpreted by the caller's shell before lark-cli receives them, producing corrupted or incomplete Feishu messages.The shortcut framework already has validated
@fileand stdin input resolution. The IM send/reply body flags simply did not opt into it.User impact
Agents and scripts can safely send exact long-form content without shell interpolation:
lark-cli im +messages-send --chat-id oc_xxx --markdown @./message.md generate-message | lark-cli im +messages-send --chat-id oc_xxx --markdown -Validation
git diff --check$HOME,$(), and Chinese contentSummary by CodeRabbit
New Features
--content,--text, and--markdown.Bug Fixes