Skip to content

Commit 264d0b1

Browse files
committed
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.
1 parent 966cf5e commit 264d0b1

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/lib/version-check.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ const JITTER_FACTOR = 0.2;
2424
/** Commands/flags that should not show update notifications */
2525
const SUPPRESSED_ARGS = new Set([
2626
"upgrade",
27-
"setup",
28-
"fix",
2927
"--version",
3028
"-V",
3129
"--json",
3230
"token",
3331
]);
3432

33+
/**
34+
* CLI management subcommands that should not trigger version checks.
35+
* Matched only when preceded by "cli" to avoid false positives
36+
* (e.g., `--project setup` should not suppress notifications).
37+
*/
38+
const SUPPRESSED_CLI_SUBCOMMANDS = new Set(["setup", "fix"]);
39+
3540
/** AbortController for pending version check fetch */
3641
let pendingAbortController: AbortController | null = null;
3742

@@ -65,7 +70,14 @@ function shouldCheckForUpdate(): boolean {
6570
* Check if update notifications should be suppressed for these args.
6671
*/
6772
export function shouldSuppressNotification(args: string[]): boolean {
68-
return args.some((arg) => SUPPRESSED_ARGS.has(arg));
73+
if (args.some((arg) => SUPPRESSED_ARGS.has(arg))) {
74+
return true;
75+
}
76+
// Suppress for "cli <subcommand>" management commands (setup, fix)
77+
if (args[0] === "cli" && SUPPRESSED_CLI_SUBCOMMANDS.has(args[1] ?? "")) {
78+
return true;
79+
}
80+
return false;
6981
}
7082

7183
/**

test/lib/version-check.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ describe("shouldSuppressNotification", () => {
3939
expect(shouldSuppressNotification(["cli", "feedback"])).toBe(false);
4040
});
4141

42+
test("does not suppress when setup/fix appear as non-cli args", () => {
43+
expect(
44+
shouldSuppressNotification(["issue", "list", "--project", "setup"])
45+
).toBe(false);
46+
expect(
47+
shouldSuppressNotification(["issue", "list", "--query", "fix"])
48+
).toBe(false);
49+
});
50+
4251
test("suppresses for --version flag", () => {
4352
expect(shouldSuppressNotification(["--version"])).toBe(true);
4453
expect(shouldSuppressNotification(["-V"])).toBe(true);

0 commit comments

Comments
 (0)