diff --git a/src/lib/error-reporting.ts b/src/lib/error-reporting.ts index ac145c6e5..15ddb015e 100644 --- a/src/lib/error-reporting.ts +++ b/src/lib/error-reporting.ts @@ -50,6 +50,7 @@ type SilenceReason = | "output_error" | "context_missing" | "auth_expected" + | "validation_error" | "api_user_error" | "api_query_error" | "network_error"; @@ -91,6 +92,13 @@ export function classifySilenced(error: unknown): SilenceReason | null { if (error instanceof AuthError) { return "auth_expected"; } + // A ValidationError means the user supplied malformed input (e.g. a project + // slug where a 32-char hex trace ID was required). It is never a CLI bug — + // the CLI correctly rejects the input and displays an actionable message. + // Silence it so it does not pollute Sentry as an unhandled error (CLI-1GP). + if (error instanceof ValidationError) { + return "validation_error"; + } if (error instanceof ApiError && error.status > 400 && error.status < 500) { return "api_user_error"; } diff --git a/test/lib/error-reporting.test.ts b/test/lib/error-reporting.test.ts index 75582ded8..aa3250945 100644 --- a/test/lib/error-reporting.test.ts +++ b/test/lib/error-reporting.test.ts @@ -308,12 +308,17 @@ describe("classifySilenced", () => { expect(classifySilenced(err)).toBe("context_missing"); }); + test("silences ValidationError (user-supplied malformed input)", () => { + expect(classifySilenced(new ValidationError("bad"))).toBe( + "validation_error", + ); + }); + test.each([ [ "ResolutionError", new ResolutionError("Project 'x'", "not found", "sentry issue list"), ], - ["ValidationError", new ValidationError("bad")], ["SeerError", new SeerError("not_enabled")], ["ConfigError", new ConfigError("bad")], ["generic Error", new Error("boom")],