You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(okr,whiteboard): surface input errors as typed error envelopes
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.
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--file is required").WithParam("--file")
47
48
}
48
49
ext:=strings.ToLower(filepath.Ext(filePath))
49
50
if!allowedImageExts[ext] {
50
-
returncommon.FlagErrorf("--file must be an image (supported: JPG, JPEG, PNG, GIF, BMP), got %q", ext)
51
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--file must be an image (supported: JPG, JPEG, PNG, GIF, BMP), got %q", ext).WithParam("--file")
51
52
}
52
53
53
54
targetID:=runtime.Str("target-id")
54
55
iftargetID=="" {
55
-
returncommon.FlagErrorf("--target-id is required")
56
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--target-id is required").WithParam("--target-id")
returnnil, common.FlagErrorf("--progress-percent must be a number between -99999999999 and 99999999999")
64
+
returnnil, errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must be a number between -99999999999 and 99999999999").WithParam("--progress-percent")
64
65
}
65
66
progressRate=&ProgressRateV1{Percent: &percent}
66
67
ifs:=runtime.Str("progress-status"); s!="" {
67
68
status, ok:=ParseProgressStatus(s)
68
69
if!ok {
69
-
returnnil, common.FlagErrorf("--progress-status must be one of: normal | overdue | done")
70
+
returnnil, errs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-status must be one of: normal | overdue | done").WithParam("--progress-status")
70
71
}
71
72
progressRate.Status=int32Ptr(int32(status))
72
73
}
@@ -105,31 +106,31 @@ var OKRCreateProgressRecord = common.Shortcut{
returncommon.FlagErrorf("--progress-percent must be a number between -99999999999 and 99999999999")
150
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must be a number between -99999999999 and 99999999999").WithParam("--progress-percent")
150
151
}
151
152
}
152
153
ifv:=runtime.Str("progress-status"); v!="" {
153
154
if_, ok:=ParseProgressStatus(v); !ok {
154
-
returncommon.FlagErrorf("--progress-status must be one of: normal | overdue | done")
155
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-status must be one of: normal | overdue | done").WithParam("--progress-status")
155
156
}
156
157
ifv:=runtime.Str("progress-percent"); v=="" {
157
-
returncommon.FlagErrorf("--progress-percent must provided with --progress-status")
158
+
returnerrs.NewValidationError(errs.SubtypeInvalidArgument, "--progress-percent must provided with --progress-status").WithParam("--progress-percent")
0 commit comments