From 966cf5e53524b284d0797d182b8e872c67f10d67 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Mon, 16 Feb 2026 22:39:45 +0000 Subject: [PATCH 1/2] fix(telemetry): reduce noise from version-check JSON parse errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace captureException with span attributes for background version check errors (network failures, truncated JSON from GitHub API). These are transient infrastructure issues, not CLI bugs — recording them as span attributes keeps them queryable in Discover without creating Issues. Also suppress the background version check for `sentry cli setup` and `sentry cli fix`, which are CLI management commands where update notifications are irrelevant. Fixes CLI-K Fixes CLI-5J --- src/lib/version-check.ts | 11 +++++++++-- test/lib/version-check.test.ts | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/lib/version-check.ts b/src/lib/version-check.ts index cd5cd495..d4c76f22 100644 --- a/src/lib/version-check.ts +++ b/src/lib/version-check.ts @@ -24,6 +24,8 @@ const JITTER_FACTOR = 0.2; /** Commands/flags that should not show update notifications */ const SUPPRESSED_ARGS = new Set([ "upgrade", + "setup", + "fix", "--version", "-V", "--json", @@ -107,9 +109,14 @@ function checkForUpdateInBackgroundImpl(): void { setVersionCheckInfo(latestVersion); span.setStatus({ code: 1 }); // OK } catch (error) { - // Don't report abort errors - they're expected when process exits + // Don't report abort errors - they're expected when process exits. + // Record other errors (network failures, JSON parse errors) as span + // attributes rather than captureException — these are transient + // infrastructure issues (GitHub rate limits, CDN errors), not CLI bugs. + // They remain queryable in Discover without cluttering the Issues feed. if (error instanceof Error && error.name !== "AbortError") { - Sentry.captureException(error); + span.setAttribute("version_check.error", error.message); + span.setAttribute("version_check.error_type", error.constructor.name); } span.setStatus({ code: 2 }); // Error } finally { diff --git a/test/lib/version-check.test.ts b/test/lib/version-check.test.ts index 44fc384e..3436b683 100644 --- a/test/lib/version-check.test.ts +++ b/test/lib/version-check.test.ts @@ -21,6 +21,24 @@ describe("shouldSuppressNotification", () => { expect(shouldSuppressNotification(["upgrade", "--check"])).toBe(true); }); + test("suppresses for cli management commands", () => { + expect(shouldSuppressNotification(["cli", "setup"])).toBe(true); + expect(shouldSuppressNotification(["cli", "fix"])).toBe(true); + expect( + shouldSuppressNotification([ + "cli", + "setup", + "--install", + "--method", + "curl", + ]) + ).toBe(true); + }); + + test("does not suppress for cli feedback", () => { + expect(shouldSuppressNotification(["cli", "feedback"])).toBe(false); + }); + test("suppresses for --version flag", () => { expect(shouldSuppressNotification(["--version"])).toBe(true); expect(shouldSuppressNotification(["-V"])).toBe(true); From 264d0b1104f774f3ce3a97a7286a0698c50b1dc1 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Mon, 16 Feb 2026 22:46:26 +0000 Subject: [PATCH 2/2] fix: scope cli subcommand suppression to avoid false positives Address BugBot review: use positional matching (args[0]==="cli") for setup/fix instead of bare SUPPRESSED_ARGS membership, so commands like `sentry issue list --project setup` are not falsely suppressed. --- src/lib/version-check.ts | 18 +++++++++++++++--- test/lib/version-check.test.ts | 9 +++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/lib/version-check.ts b/src/lib/version-check.ts index d4c76f22..6118d69e 100644 --- a/src/lib/version-check.ts +++ b/src/lib/version-check.ts @@ -24,14 +24,19 @@ const JITTER_FACTOR = 0.2; /** Commands/flags that should not show update notifications */ const SUPPRESSED_ARGS = new Set([ "upgrade", - "setup", - "fix", "--version", "-V", "--json", "token", ]); +/** + * CLI management subcommands that should not trigger version checks. + * Matched only when preceded by "cli" to avoid false positives + * (e.g., `--project setup` should not suppress notifications). + */ +const SUPPRESSED_CLI_SUBCOMMANDS = new Set(["setup", "fix"]); + /** AbortController for pending version check fetch */ let pendingAbortController: AbortController | null = null; @@ -65,7 +70,14 @@ function shouldCheckForUpdate(): boolean { * Check if update notifications should be suppressed for these args. */ export function shouldSuppressNotification(args: string[]): boolean { - return args.some((arg) => SUPPRESSED_ARGS.has(arg)); + if (args.some((arg) => SUPPRESSED_ARGS.has(arg))) { + return true; + } + // Suppress for "cli " management commands (setup, fix) + if (args[0] === "cli" && SUPPRESSED_CLI_SUBCOMMANDS.has(args[1] ?? "")) { + return true; + } + return false; } /** diff --git a/test/lib/version-check.test.ts b/test/lib/version-check.test.ts index 3436b683..d93e06cf 100644 --- a/test/lib/version-check.test.ts +++ b/test/lib/version-check.test.ts @@ -39,6 +39,15 @@ describe("shouldSuppressNotification", () => { expect(shouldSuppressNotification(["cli", "feedback"])).toBe(false); }); + test("does not suppress when setup/fix appear as non-cli args", () => { + expect( + shouldSuppressNotification(["issue", "list", "--project", "setup"]) + ).toBe(false); + expect( + shouldSuppressNotification(["issue", "list", "--query", "fix"]) + ).toBe(false); + }); + test("suppresses for --version flag", () => { expect(shouldSuppressNotification(["--version"])).toBe(true); expect(shouldSuppressNotification(["-V"])).toBe(true);