Skip to content

feat(mail): strict local validation for message_ids in +messages#1194

Closed
xukuncx wants to merge 1 commit into
larksuite:mainfrom
xukuncx:feat/7564d1a
Closed

feat(mail): strict local validation for message_ids in +messages#1194
xukuncx wants to merge 1 commit into
larksuite:mainfrom
xukuncx:feat/7564d1a

Conversation

@xukuncx
Copy link
Copy Markdown
Collaborator

@xukuncx xukuncx commented Jun 1, 2026

Generated by the harness-coding skill.

  • Branch: feat/7564d1a
  • Target: main

Sprints

ID Title Status Commit
S1 Add strict local validation for message_ids in mail +messages shortcut passed 2a51a24
S2 Synthesize transport contract for larksuite/cli passed 99e314f

Source specs

  • (lightweight mode — no tech-spec files)

This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation for the +messages shortcut's message IDs, catching invalid formats earlier and returning clearer error messages to help users correct formatting issues.
  • Tests

    • Added comprehensive unit test coverage for message ID validation logic.

…shortcut

Add validateMessageIDs function that checks each message ID after
comma splitting to reject clearly illegal input before it reaches the
batch_get API endpoint. Rejects empty/whitespace IDs, natural language,
JSON array strings, colon-separated IDs, and quote-wrapped values.
Strip surrounding quotes before validation. Add comprehensive unit tests.

sprint: S1
@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.


xukun 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd92e47e-cf63-4210-803d-999b2ed52e5c

📥 Commits

Reviewing files that changed from the base of the PR and between 99e314f and 2a51a24.

📒 Files selected for processing (2)
  • shortcuts/mail/mail_messages.go
  • shortcuts/mail/mail_messages_test.go

📝 Walkthrough

Walkthrough

This PR enhances the mail +messages shortcut by adding comprehensive input validation for the --message-ids flag. A new validation pipeline rejects malformed IDs early, enforcing opaque-identifier rules via regex and natural-language heuristics, with aggregated error reporting and full test coverage.

Changes

Message ID Validation

Layer / File(s) Summary
Message ID validation helpers and patterns
shortcuts/mail/mail_messages.go
Introduces regex pattern (messageIDPattern) restricting ID character sets and commonEnglishWords list for heuristic detection. validateSingleMessageID applies multi-stage cleaning (trim, quote-strip) and rejection rules (empty, JSON-like, colon-separated, spaces, English words) before regex enforcement. validateMessageIDs accumulates per-ID failures into a single output.ErrValidation.
Validate method integration
shortcuts/mail/mail_messages.go
Extends MailMessages.Validate to validate comma-split --message-ids after validateBotMailboxNotMe, replacing prior single-check flow with the new aggregating validation pipeline.
Message ID validation test suites
shortcuts/mail/mail_messages_test.go
TestValidateMessageIDs exercises list-level validation with table-driven cases covering empty/whitespace, natural-language/spacing, JSON-array patterns, quote-handling, and colon-separated formats. TestValidateSingleMessageID validates individual ID rejection reasons across whitespace, JSON-like strings, colon-separated inputs, quote-wrapped values, and character patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • larksuite/cli#895: Both PRs modify shortcuts/mail/mail_messages.go to integrate validateBotMailboxNotMe into the +messages shortcut's Validate hook.

Suggested labels

domain/mail, size/M

Suggested reviewers

  • chanthuang

Poem

🐰 A rabbit hops through message IDs,
Checking for whitespace and colons (forbids!),
Rejecting the gibberish, quotes, and the mess,
Now your mail shortcuts pass the strictness test! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks required template sections (Summary, Changes, Test Plan, Related Issues) and instead provides auto-generated metadata. Required summary, detailed changes, and test plan information are missing. Provide a description following the template with sections for Summary, Changes, Test Plan, and Related Issues. Include why validation was needed and how changes were tested.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding strict local validation for message_ids in the mail +messages shortcut.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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/mail PR touches the mail domain size/M Single-domain feat or fix with limited business impact labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add xukuncx/cli#feat/7564d1a -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.15%. Comparing base (99e314f) to head (2a51a24).

Files with missing lines Patch % Lines
shortcuts/mail/mail_messages.go 94.11% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1194      +/-   ##
==========================================
+ Coverage   69.14%   69.15%   +0.01%     
==========================================
  Files         630      630              
  Lines       59304    59336      +32     
==========================================
+ Hits        41005    41035      +30     
- Misses      14988    14989       +1     
- Partials     3311     3312       +1     

☔ 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.

@xukuncx xukuncx closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/mail PR touches the mail 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.

2 participants