fix: use ErrValidation instead of fmt.Errorf in Validate paths#1001
fix: use ErrValidation instead of fmt.Errorf in Validate paths#1001mengqiuzhen wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughValidation error returns in mail and sheets shortcuts were changed to use the centralized ChangesValidation Error Standardization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1001 +/- ##
==========================================
+ Coverage 67.66% 67.67% +0.01%
==========================================
Files 576 576
Lines 54510 54510
==========================================
+ Hits 36885 36891 +6
+ Misses 14566 14561 -5
+ Partials 3059 3058 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@1d0b996c3af908c7c5ae2f26c8408352a8ad897e🧩 Skill updatenpx skills add mengqiuzhen/Feishu-cli#fix/validate-fmt-errorf-consistency -y -g |
1d0b996 to
9d21388
Compare
|
CI is failing due to a goimports formatting error:
|
161a1f7 to
4569d96
Compare
Replace 8 bare fmt.Errorf calls with output.ErrValidation across 3 files so validation errors consistently return structured JSON (type: validation, exit 2) matching the rest of the codebase. Affected functions: validateExpectedFlag (sheets), validateSendTime, validateComposeInlineAndAttachments, validateEventFlags (mail), validateSignatureWithPlainText (mail) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/mail/signature_compose.go (1)
6-21:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winFix import ordering as requested by reviewer.
As noted in the PR comments, there's an import ordering issue in this file. Please run
goimports -w shortcuts/mail/signature_compose.goto fix the import order before merging.🤖 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/mail/signature_compose.go` around lines 6 - 21, The import block in signature_compose.go is not ordered/formatted per project/goimports conventions; run goimports to reorder and format imports (e.g., run `goimports -w shortcuts/mail/signature_compose.go`) or manually reorder to group standard library, third-party, and internal imports, then save; ensure the import list around the package references like emlbuilder, signature, draftpkg, common, and output remains correct and builds.
🤖 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.
Outside diff comments:
In `@shortcuts/mail/signature_compose.go`:
- Around line 6-21: The import block in signature_compose.go is not
ordered/formatted per project/goimports conventions; run goimports to reorder
and format imports (e.g., run `goimports -w
shortcuts/mail/signature_compose.go`) or manually reorder to group standard
library, third-party, and internal imports, then save; ensure the import list
around the package references like emlbuilder, signature, draftpkg, common, and
output remains correct and builds.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 78509dc5-6dfb-4162-9a10-b35b19e1601e
📒 Files selected for processing (3)
shortcuts/mail/helpers.goshortcuts/mail/signature_compose.goshortcuts/sheets/lark_sheets_filter_views.go
|
Thanks for the review! The goimports issue in signature_compose.go was fixed and force-pushed (commit 4569d96). The latest CI run is still waiting for approval — could you approve it to verify the fix passes? |
Summary
8 bare
fmt.Errorfcalls in Validate paths (across 3 files) returned unstructured errors without the standardtype: validationJSON envelope and exit code 2. Replaced withoutput.ErrValidationfor consistency with the rest of the codebase.Changes
shortcuts/sheets/lark_sheets_filter_views.govalidateExpectedFlagfmt.Errorf→ErrValidation+ importshortcuts/mail/helpers.govalidateSendTime,validateComposeInlineAndAttachments,validateEventFlagsfmt.Errorf→ErrValidationshortcuts/mail/signature_compose.govalidateSignatureWithPlainTextfmt.Errorf→ErrValidation+ importVerification
go build ./...— cleango test ./shortcuts/sheets/... ./shortcuts/mail/...— pre-existing failures only (Windows CRLF golden files, sheets image paths), unrelated to this change🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Bug Fixes