Validate mail shortcut mailbox IDs before requests#1442
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds validateUserMailboxID helper and applies it in MailMessage and MailTriage Validate flows; unit and integration tests ensure invalid --mailbox values are rejected before runtime/HTTP output. ChangesMailbox ID validation for mail shortcuts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 `@shortcuts/mail/mail_shortcut_validation_test.go`:
- Around line 184-256: Update the failing-branch tests to assert typed
validation metadata instead of only message substrings: replace or augment the
assertValidationError calls in TestValidateUserMailboxID (the invalid mailbox
loop), TestMailMessageInvalidMailboxValidationStopsBeforeHTTP, and
TestMailTriageInvalidMailboxValidationStopsDryRun by calling errs.ProblemOf(err)
and asserting its category/subtype match the validation error, and use
errors.As(err, &ve) with ve of type *errs.ValidationError to assert ve.Param ==
"--mailbox"; keep the existing substring checks only as optional extra info.
Ensure you reference validateUserMailboxID when validating unit tests and the
runMountedMailShortcut/MailTriage/MailMessage test branches so the typed
assertions run on the same error values.
🪄 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: 9f21db4e-93f0-4faf-9cfd-c852b8d3ee5c
📒 Files selected for processing (4)
shortcuts/mail/helpers.goshortcuts/mail/mail_message.goshortcuts/mail/mail_shortcut_validation_test.goshortcuts/mail/mail_triage.go
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1442 +/- ##
==========================================
+ Coverage 72.86% 72.89% +0.02%
==========================================
Files 738 738
Lines 69552 69569 +17
==========================================
+ Hits 50679 50711 +32
+ Misses 15057 15043 -14
+ Partials 3816 3815 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@2a34ab84121c46a5dacdbcfe97be43a21f50a924🧩 Skill updatenpx skills add bubbmon233/cli#feat/35d1f60 -y -g |
Change-Type: ci-fix
| if err := validateBotMailboxNotMe(runtime); err != nil { | ||
| return err | ||
| } | ||
| return validateUserMailboxID("--mailbox", resolveMailboxID(runtime)) |
There was a problem hiding this comment.
🤖 AI Review | [P2 正确性] bot 身份下显式空 mailbox 会绕过 me 校验
resolveMailboxID 会把空字符串归一成 me,但这里先调用的 validateBotMailboxNotMe 只检查原始 runtime.Str("mailbox") == "me"。因此 mail +message --as bot --mailbox "" 会通过 Validate,随后 dry-run/execute 继续生成 /user_mailboxes/me/...;+triage 同样有这个顺序。业务影响:bot 使用 tenant token 时无法解析 me,本应被本地参数校验拦截的请求会进入错误路径或误导 dry-run 输出。
修复建议: 先解析一次 mailboxID := resolveMailboxID(runtime),并让 bot/me 校验基于解析后的值;同时补 --as bot --mailbox "" 的 +message 和 +triage 测试。
如有疑问或认为判断不准确,欢迎直接回复讨论。
|
🤖 AI Review | CR 汇总 | 可合入(1 个建议项) 增量审查:基于已有 1 条已解决评论,本次新增 1 条 P2 正确性建议。核心实现符合需求,但建议补齐 |
Generated by the harness-coding skill.
Sprints
Source specs
This MR was created autonomously. Quality gates were enforced by the repo's own pre-commit hooks.
Summary by CodeRabbit