Skip to content

fix(mail): clarify that file path flags only accept relative paths#141

Merged
infeng merged 1 commit intolarksuite:mainfrom
infeng:docs/mail-relative-path-hints
Mar 31, 2026
Merged

fix(mail): clarify that file path flags only accept relative paths#141
infeng merged 1 commit intolarksuite:mainfrom
infeng:docs/mail-relative-path-hints

Conversation

@infeng
Copy link
Copy Markdown
Collaborator

@infeng infeng commented Mar 31, 2026

Summary

Update --attach, --inline, and --patch-file flag descriptions across all mail shortcuts and reference docs to explicitly state that only relative paths are accepted, fixing the issue where AI models would pass absolute paths (e.g. /tmp/patch.json) when using lark-cli mail commands.

Changes

  • Updated flag Desc in 6 shortcut Go files (draft-create, draft-edit, send, reply, reply-all, forward) to mention "relative path only"
  • Updated buildDraftEditPatchTemplate() shape descriptions and notes to reflect relative path constraint
  • Updated 6 reference markdown docs with relative path hints and replaced /tmp/patch.json examples with ./patch.json

Test Plan

  • make unit-test passed
  • Verified all 6 shortcuts and 6 reference docs are consistently updated

@infeng infeng requested a review from chanthuang March 31, 2026 08:54
@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR clarifies that --attach, --inline, and --patch-file flags only accept relative paths across all six mail shortcuts (+draft-create, +draft-edit, +send, +reply, +reply-all, +forward) and their corresponding reference markdown docs. The change is entirely documentation/description-level — no runtime logic is altered.

The enforcement was already in place before this PR: validate.SafeInputPath is called at file-read time (via emlbuilder.readFile for attachments/inline images, and directly in loadPatchFile for --patch-file), which rejects absolute paths and directory-traversal attempts. This PR surfaces that constraint upfront in flag descriptions and skill reference docs so AI models are less likely to supply paths like /tmp/patch.json in the first place.

Key changes:

  • All 6 shortcut Go files: --attach Desc appended with "(relative path only)"; --inline Desc updated to use <relative-path> and "All file_path values must be relative paths"; --patch-file Desc in +draft-edit appended with "Relative path only."
  • buildDraftEditPatchTemplate() already carried \"string(relative path)\" annotations on add_attachment, add_inline, and replace_inline ops; patch_file_example updated from /tmp/patch.json to ./patch.json.
  • All 6 reference markdown docs: parameter tables annotated with "相对路径" (relative path); /tmp/ example paths replaced with ./-prefixed relative paths.

Confidence Score: 5/5

Safe to merge — purely a documentation clarification with no logic changes; enforcement was already present via validate.SafeInputPath.

All 6 shortcuts and all 6 reference docs are consistently updated. The "relative path only" constraint is real and already enforced at runtime. No new logic is introduced and no existing validation is weakened. The fix directly addresses the reported problem of AI models passing absolute paths.

No files require special attention.

Important Files Changed

Filename Overview
shortcuts/mail/mail_draft_create.go Updated --attach and --inline flag Desc strings to add "(relative path only)" and "" hints; logic unchanged.
shortcuts/mail/mail_draft_edit.go Added "Relative path only." to --patch-file flag Desc; buildDraftEditPatchTemplate() supported_ops and notes already carried relative-path annotations; patch_file_example updated from /tmp/patch.json to ./patch.json.
shortcuts/mail/mail_send.go Appended "(relative path only)" to --attach Desc and updated --inline Desc with relative-path language; no logic changes.
shortcuts/mail/mail_reply.go Same doc-only change as mail_send.go — "(relative path only)" added to --attach; --inline Desc updated to match.
shortcuts/mail/mail_reply_all.go Same doc-only change as mail_reply.go; no logic differences.
shortcuts/mail/mail_forward.go Same doc-only change as other compose shortcuts; "(relative path only)" appended to --attach Desc for the forward-specific wording.
skills/lark-mail/references/lark-mail-draft-edit.md Reference doc updated: --patch-file table row now says "相对路径" (relative path); note section clarifies all file paths must be relative; already used ./patch.json in examples.
skills/lark-mail/references/lark-mail-send.md Parameter table updated to annotate --attach with "相对路径" and --inline with "(相对路径)"; examples use ./-prefixed paths throughout.
skills/lark-mail/references/lark-mail-draft-create.md Parameter table and examples updated to state "相对路径" for --attach and file_path; examples use ./ prefix consistently.
skills/lark-mail/references/lark-mail-forward.md Same reference-doc update as lark-mail-send.md — relative-path annotations added to parameter table for --attach and --inline.
skills/lark-mail/references/lark-mail-reply.md Same reference-doc update as lark-mail-forward.md.
skills/lark-mail/references/lark-mail-reply-all.md Same reference-doc update as lark-mail-reply.md.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[AI model invokes mail shortcut] --> B{Flag type}
    B -->|--attach| C["Flag Desc now says 'relative path only'"]
    B -->|--inline file_path| D["Flag Desc now says 'relative path only'"]
    B -->|--patch-file| E["Flag Desc now says 'Relative path only.'"]
    C --> F[splitByComma → bld.AddFileAttachment]
    D --> G[parseInlineSpecs → bld.AddFileInline]
    E --> H[loadPatchFile → validate.SafeInputPath]
    F --> I[emlbuilder.readFile → validate.SafeInputPath]
    G --> I
    H --> I
    I -->|Absolute path| J["❌ Error: must be a relative path within the current directory"]
    I -->|Relative path| K["✅ File read succeeds — EML built and draft created"]
Loading

Reviews (1): Last reviewed commit: "fix(mail): clarify that file path flags ..." | Re-trigger Greptile

@infeng infeng merged commit 1ffe870 into larksuite:main Mar 31, 2026
4 checks passed
infeng added a commit to infeng/cli that referenced this pull request Apr 1, 2026
infeng added a commit to infeng/cli that referenced this pull request Apr 1, 2026
infeng added a commit that referenced this pull request Apr 1, 2026
* Revert "fix(mail): clarify that file path flags only accept relative paths (#141)"

This reverts commit 1ffe870.

* Revert "feat(mail): auto-resolve local image paths in draft body HTML (#81) (#139)"

This reverts commit 70c72a2.

* Reapply "fix(mail): clarify that file path flags only accept relative paths (#141)"

This reverts commit d465e08.
tuxedomm pushed a commit that referenced this pull request Apr 3, 2026
* Revert "fix(mail): clarify that file path flags only accept relative paths (#141)"

This reverts commit eac6fa9.

* Revert "feat(mail): auto-resolve local image paths in draft body HTML (#81) (#139)"

This reverts commit 22cc882.

* Reapply "fix(mail): clarify that file path flags only accept relative paths (#141)"

This reverts commit d465e08.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants