diff --git a/src/lib/error-reporting.ts b/src/lib/error-reporting.ts index ac145c6e5..17d27e5d0 100644 --- a/src/lib/error-reporting.ts +++ b/src/lib/error-reporting.ts @@ -52,7 +52,8 @@ type SilenceReason = | "auth_expected" | "api_user_error" | "api_query_error" - | "network_error"; + | "network_error" + | "validation_error"; /** * Classify whether an error should be silenced. @@ -82,6 +83,15 @@ export function classifySilenced(error: unknown): SilenceReason | null { if (error instanceof ContextError) { return "context_missing"; } + // A ValidationError with field "positional" means the user passed the wrong + // number of positional arguments — a user invocation mistake, never a CLI + // bug. Silence only this sub-case; other ValidationError fields (e.g. + // "installUrl" from buildFormatFromUrl) may reflect API-contract issues + // worth capturing. The `cli.error.silenced` metric preserves the volume. + // (CLI-1AN) + if (error instanceof ValidationError && error.field === "positional") { + return "validation_error"; + } // All AuthError reasons are expected auth states the user must act on, not // CLI bugs: `not_authenticated` (no token), `expired` (token aged out), and // `invalid` (a bad/insufficiently-scoped token the user supplied). `invalid`