feat(okr,whiteboard): surface input errors as typed error envelopes#1236
feat(okr,whiteboard): surface input errors as typed error envelopes#1236evandance wants to merge 1 commit into
Conversation
Invalid flags, malformed input payloads, and output-file conflicts in the okr and whiteboard commands now return structured error envelopes — each carrying a stable category, subtype, and the offending flag — instead of flat strings. Scripts and agents can branch on the error shape and exit code rather than scraping messages. API-response errors in these commands keep the existing envelopes for now; they convert in a follow-up once the shared typed API path is available.
📝 WalkthroughWalkthroughThis PR systematically migrates CLI validation error handling across OKR and whiteboard shortcuts from legacy helpers ( ChangesCLI Validation Error Type Migration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 #1236 +/- ##
=======================================
Coverage 69.22% 69.22%
=======================================
Files 635 635
Lines 59687 59689 +2
=======================================
+ Hits 41320 41322 +2
Misses 15033 15033
Partials 3334 3334 ☔ 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@0b7e0274d6d8bf6d9ace7e9db903edd5dfccad4e🧩 Skill updatenpx skills add larksuite/cli#feat/errs-migrate-okr-whiteboard -y -g |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
shortcuts/okr/okr_progress_update.go (1)
108-110:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winGrammar: "must provided" → "must be provided".
Same wording issue as
okr_progress_create.goLine 158.✏️ Proposed fix
- return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must provided with --progress-status").WithParam("--progress-percent") + return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must be provided with --progress-status").WithParam("--progress-percent")🤖 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/okr/okr_progress_update.go` around lines 108 - 110, Update the validation error message that currently reads "--progress-percent must provided with --progress-status" to correct grammar: "--progress-percent must be provided with --progress-status". Change the string in the code path where runtime.Str("progress-percent") == "" (the errs.NewValidationError(...) call) and make the identical change in the similar message in okr_progress_create.go to keep wording consistent.
🤖 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/okr/okr_progress_create.go`:
- Around line 157-159: Update the user-facing validation error message to
correct the grammar: change the string returned when
runtime.Str("progress-percent") is empty inside the create handler (the block
that returns errs.NewValidationError(...).WithParam("--progress-percent")) from
" --progress-percent must provided with --progress-status" to "
--progress-percent must be provided with --progress-status" so the message reads
" --progress-percent must be provided with --progress-status".
---
Duplicate comments:
In `@shortcuts/okr/okr_progress_update.go`:
- Around line 108-110: Update the validation error message that currently reads
"--progress-percent must provided with --progress-status" to correct grammar:
"--progress-percent must be provided with --progress-status". Change the string
in the code path where runtime.Str("progress-percent") == "" (the
errs.NewValidationError(...) call) and make the identical change in the similar
message in okr_progress_create.go to keep wording consistent.
🪄 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: 905c6ac6-b988-44a3-b7aa-4fed629d6643
📒 Files selected for processing (13)
shortcuts/okr/okr_cycle_detail.goshortcuts/okr/okr_cycle_detail_test.goshortcuts/okr/okr_cycle_list.goshortcuts/okr/okr_image_upload.goshortcuts/okr/okr_progress_create.goshortcuts/okr/okr_progress_delete.goshortcuts/okr/okr_progress_get.goshortcuts/okr/okr_progress_list.goshortcuts/okr/okr_progress_update.goshortcuts/whiteboard/whiteboard_query.goshortcuts/whiteboard/whiteboard_query_test.goshortcuts/whiteboard/whiteboard_update.goshortcuts/whiteboard/whiteboard_update_test.go
| if v := runtime.Str("progress-percent"); v == "" { | ||
| return common.FlagErrorf("--progress-percent must provided with --progress-status") | ||
| return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must provided with --progress-status").WithParam("--progress-percent") | ||
| } |
There was a problem hiding this comment.
Grammar: "must provided" → "must be provided".
User-facing error string reads ungrammatically.
✏️ Proposed fix
- return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must provided with --progress-status").WithParam("--progress-percent")
+ return errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must be provided with --progress-status").WithParam("--progress-percent")🤖 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/okr/okr_progress_create.go` around lines 157 - 159, Update the
user-facing validation error message to correct the grammar: change the string
returned when runtime.Str("progress-percent") is empty inside the create handler
(the block that returns
errs.NewValidationError(...).WithParam("--progress-percent")) from "
--progress-percent must provided with --progress-status" to " --progress-percent
must be provided with --progress-status" so the message reads "
--progress-percent must be provided with --progress-status".
Summary
Migrates input-side and local-side errors in the okr and whiteboard commands to
the typed
errs.*envelope. Invalid flags, malformed input payloads, andoutput-file conflicts now carry a stable category, subtype, and the offending
flag, so scripts and agents can branch on error shape and exit code instead of
scraping message strings. No success-path behavior changes.
This is stage 1 of 2. The raw-API boundary stays on the existing envelopes under
TODO(errs-migrate)markers and converts in a follow-up once the shared typedAPI path (
runtime.CallAPITyped/ClassifyAPIResponse) lands on main.Changes
output.Err*/common.FlagErrorf→
errs.NewValidationError(SubtypeInvalidArgument).WithParam("--flag")anderrs.NewInternalError(...)for local file I/O.errors.As/errs.ProblemOf,subtype, offending param) survives command dispatch.
TODO(errs-migrate)for the stage-2 follow-up.Test Plan
gofmt -l,go vet,go build ./...: cleango test ./shortcuts/okr/... ./shortcuts/whiteboard/...: passgolangci-lint run --new-from-rev=origin/main(both domains): 0 issuesgo run -C lint . ..): 0 violationsRelated Issues
Part of the cli-errors-refactor domain migration.
Summary by CodeRabbit
Improvements
Tests