Skip to content

docs(im): clarify media key formats for message media flags#991

Merged
liangshuo-1 merged 2 commits into
larksuite:mainfrom
YangJunzhou-01:fix/pr-956-improved
May 20, 2026
Merged

docs(im): clarify media key formats for message media flags#991
liangshuo-1 merged 2 commits into
larksuite:mainfrom
YangJunzhou-01:fix/pr-956-improved

Conversation

@YangJunzhou-01

@YangJunzhou-01 YangJunzhou-01 commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Based on #956 by @mtsui-cmyk

  • Clarify im +messages-send and im +messages-reply media flag help text by explicitly documenting img_xxx and file_xxx key formats.
  • Update the corresponding lark-im skill references so send/reply media parameter docs match the CLI help text.
  • Keep existing local path and URL behavior unchanged.

Related Issues

Fixes #872

Summary by CodeRabbit

  • Documentation
    • Clarified IM message command docs and flag help to specify accepted media inputs: media keys, http(s) URLs, or cwd-relative local paths; noted absolute paths and parent-directory references are rejected and that video flags must be paired.
  • Tests
    • Added a validation test ensuring media flag descriptions document the new path and URL rules.

Review Change Stack

@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 20, 2026
@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3edfff67-bfc7-4470-ae02-c8c80f7bb436

📥 Commits

Reviewing files that changed from the base of the PR and between 21771a4 and c79f45a.

📒 Files selected for processing (4)
  • shortcuts/im/im_messages_reply.go
  • shortcuts/im/im_messages_send.go
  • skills/lark-im/references/lark-im-messages-reply.md
  • skills/lark-im/references/lark-im-messages-send.md
✅ Files skipped from review due to trivial changes (3)
  • skills/lark-im/references/lark-im-messages-send.md
  • shortcuts/im/im_messages_send.go
  • shortcuts/im/im_messages_reply.go

📝 Walkthrough

Walkthrough

Updated media input flag descriptions across CLI help text, validation tests, and user documentation to explicitly document that media flags accept API keys, URLs, or cwd-relative local paths while rejecting absolute paths and ...

Changes

Media Input Path Restrictions Documentation

Layer / File(s) Summary
CLI flag help text updates
shortcuts/im/im_messages_reply.go, shortcuts/im/im_messages_send.go
Updated help text for --image, --file, --video, --video-cover, and --audio flags in both reply and send shortcuts to document accepted input forms (key/URL/cwd-relative path) and explicitly state that absolute paths and .. are rejected.
Test validation of flag descriptions
shortcuts/im/validate_media_test.go
Added TestIMMediaFlagDescriptionsDocumentPathRestrictions test that validates media flag descriptions across IM shortcuts include required documentation of path constraints (URL support, cwd-relative paths, rejection of absolute paths and ..).
User documentation for media input rules
skills/lark-im/references/lark-im-messages-reply.md, skills/lark-im/references/lark-im-messages-send.md
Added dedicated "Media Input Rules" sections documenting accepted input formats and path safety constraints; expanded Parameters tables to document all media flag forms (`path

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • sammi-bytedance
  • fangshuyu-768

Poem

🐰 A rabbit hops through documentation trails,
Where paths once hidden now appear in detail—
No more surprises hiding in the dark,
Each flag now speaks its safety guard with mark,
Cwd-relative steps, no absolute affair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: clarifying media key formats for message media flags across the im command shortcuts.
Description check ✅ Passed The description provides a clear summary, lists main changes, states testing approach, and links the related issue #872. It follows the repository template structure.
Linked Issues check ✅ Passed The PR addresses issue #872 by documenting path restrictions (cwd-relative, rejecting absolute paths and ..) in CLI help text and reference docs, fulfilling the requested remedy (B).
Out of Scope Changes check ✅ Passed All changes are in-scope: CLI help text updates, documentation updates, and validation tests for media flag descriptions, all directly addressing issue #872.

✏️ 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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

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

68-71: ⚡ Quick win

Cover key-format contract in this test too.

Please also assert the descriptions mention img_xxx and/or file_xxx so the primary doc contract from this PR is regression-tested, not just URL/path constraints.

Proposed test extension
-				for _, want := range []string{"URL", "cwd-relative local path", "absolute paths", ".. are rejected"} {
+				for _, want := range []string{"URL", "cwd-relative local path", "absolute paths", ".. are rejected"} {
 					if !strings.Contains(desc, want) {
 						t.Fatalf("%s --%s description = %q, want it to mention %q", sc.name, flagName, desc, want)
 					}
 				}
+				// Key format contract
+				if flagName == "image" || flagName == "video-cover" {
+					if !strings.Contains(desc, "img_xxx") {
+						t.Fatalf("%s --%s description = %q, want it to mention %q", sc.name, flagName, desc, "img_xxx")
+					}
+				}
+				if flagName == "file" || flagName == "video" || flagName == "audio" {
+					if !strings.Contains(desc, "file_xxx") {
+						t.Fatalf("%s --%s description = %q, want it to mention %q", sc.name, flagName, desc, "file_xxx")
+					}
+				}
🤖 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/validate_media_test.go` around lines 68 - 71, The test currently
checks that descriptions mention URL/path constraints but omits the key-format
contract; update the loop in validate_media_test.go (the block using sc.name,
flagName, desc and the []string{"URL", "cwd-relative local path", "absolute
paths", ".. are rejected"}) to also assert the description references the
key-name contract by either containing "img_" or "file_": after the existing
checks add a condition that verifies strings.Contains(desc, "img_") ||
strings.Contains(desc, "file_") and call t.Fatalf with a clear message
(including sc.name, flagName, desc and the expected key prefix) when neither is
present so the test regresses if the doc contract is removed.
🤖 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 `@skills/lark-im/references/lark-im-messages-reply.md`:
- Line 30: The table row for "Reply with media" currently implies keys are
uploaded; update the wording to say it "accepts keys/URLs/cwd-relative local
files; uploads URLs/local files automatically" so it no longer claims keys are
uploaded. Edit the cell containing "Reply with media" / the description for the
`--image` / `--file` / `--video` / `--audio` flags in lark-im-messages-reply.md
to replace the phrase implying upload with the corrected phrasing ("accepts
keys/URLs/cwd-relative local files; uploads URLs/local files automatically") so
the behavior of keys versus URLs/local files is accurately described.

In `@skills/lark-im/references/lark-im-messages-send.md`:
- Line 30: Update the table row that currently claims "Shortcut uploads keys,
URLs, or cwd-relative local files automatically" (the row for "Send image / file
/ video / audio" with options "`--image` / `--file` / `--video` / `--audio`") to
clarify that only URLs and cwd-relative local file paths are automatically
uploaded, while existing keys/identifiers are sent as-is and are not uploaded;
reword the cell to explicitly state this distinction.

---

Nitpick comments:
In `@shortcuts/im/validate_media_test.go`:
- Around line 68-71: The test currently checks that descriptions mention
URL/path constraints but omits the key-format contract; update the loop in
validate_media_test.go (the block using sc.name, flagName, desc and the
[]string{"URL", "cwd-relative local path", "absolute paths", ".. are rejected"})
to also assert the description references the key-name contract by either
containing "img_" or "file_": after the existing checks add a condition that
verifies strings.Contains(desc, "img_") || strings.Contains(desc, "file_") and
call t.Fatalf with a clear message (including sc.name, flagName, desc and the
expected key prefix) when neither is present so the test regresses if the doc
contract is removed.
🪄 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: 3e309d82-45f4-4ca9-8f82-91c1ae592559

📥 Commits

Reviewing files that changed from the base of the PR and between 9272b9d and 21771a4.

📒 Files selected for processing (5)
  • shortcuts/im/im_messages_reply.go
  • shortcuts/im/im_messages_send.go
  • shortcuts/im/validate_media_test.go
  • skills/lark-im/references/lark-im-messages-reply.md
  • skills/lark-im/references/lark-im-messages-send.md

Comment thread skills/lark-im/references/lark-im-messages-reply.md Outdated
Comment thread skills/lark-im/references/lark-im-messages-send.md Outdated
@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c79f45a8c5768df31e073a18db505bce634a2b88

🧩 Skill update

npx skills add YangJunzhou-01/cli#fix/pr-956-improved -y -g

Change-Id: I329ca0db9e7a01b774846d522d1b2a64da74233c
@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.58%. Comparing base (27a5eed) to head (c79f45a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #991   +/-   ##
=======================================
  Coverage   67.58%   67.58%           
=======================================
  Files         575      575           
  Lines       54269    54269           
=======================================
  Hits        36679    36679           
  Misses      14548    14548           
  Partials     3042     3042           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liangshuo-1
liangshuo-1 merged commit c98a49f into larksuite:main May 20, 2026
19 checks passed
@liangshuo-1 liangshuo-1 mentioned this pull request May 20, 2026
2 tasks
tuxedomm pushed a commit to zhumiaoxin/cli that referenced this pull request Jun 6, 2026
…e#991)

* docs(im): clarify media path restrictions

* docs(im): clarify file key formats for message file flags

Change-Id: I329ca0db9e7a01b774846d522d1b2a64da74233c

---------

Co-authored-by: mtsui-cmyk <mervyntsui@gmail.com>
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.

--image / --file flags reject absolute paths but --help doesn't document this

4 participants