Skip to content

Commit 587d8fd

Browse files
committed
fix(cli): set exitCode=1 when schema check fails with no permission issues
Previously, when handleSchemaIssues threw and no permission issues were detected, totalFound was 0 and the command reported 'No issues found' despite the schema check failure. Now anyFailed is checked alongside totalFound to ensure failures are always surfaced with a non-zero exit.
1 parent 2dcf852 commit 587d8fd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/commands/cli/fix.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,20 +342,26 @@ export const fixCommand = buildCommand({
342342
}
343343

344344
const totalFound = perm.found + schema.found;
345+
const anyFailed = perm.repairFailed || schema.repairFailed;
345346

346-
if (totalFound === 0) {
347+
if (totalFound === 0 && !anyFailed) {
347348
stdout.write(
348349
"No issues found. Database schema and permissions are correct.\n"
349350
);
350351
return;
351352
}
352353

353354
if (dryRun) {
354-
stdout.write("Run 'sentry cli fix' to apply fixes.\n");
355+
if (totalFound > 0) {
356+
stdout.write("Run 'sentry cli fix' to apply fixes.\n");
357+
}
358+
if (anyFailed) {
359+
proc.exitCode = 1;
360+
}
355361
return;
356362
}
357363

358-
if (perm.repairFailed || schema.repairFailed) {
364+
if (anyFailed) {
359365
proc.exitCode = 1;
360366
} else {
361367
stdout.write("All issues repaired successfully.\n");

0 commit comments

Comments
 (0)