Skip to content

Commit 6c91d2b

Browse files
committed
fix(cli): os migrate apply exits 1 when the confirmation it needs is not given
A non-interactive run (non-TTY stdin, or --json) without --yes applied nothing and exited 0; every other os migrate subcommand with a --yes gate exits 1 there. Both faces now exit 1; an interactive decline keeps exit 0. Claude-Session: https://claude.ai/code/session_01LmjU2x1faLZ39DVTFyVca6 Co-authored-by: Claude <noreply@anthropic.com>
1 parent e4d604e commit 6c91d2b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

  • packages/cli/src/commands/migrate

‎packages/cli/src/commands/migrate/apply.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,19 @@ export default class MigrateApply extends Command {
612612
}
613613

614614
// Confirmation gate. Nothing above this line has touched the database.
615+
//
616+
// [#24949] A confirmation the run needs and did not get — a non-TTY
617+
// stdin, or `--json`, without `--yes` — applies nothing and exits 1, in
618+
// both faces, as every other `os migrate` subcommand with a `--yes` gate
619+
// does (`test/migrate-confirmation-exit.pin.test.ts` holds the family to
620+
// it). It used to exit 0, so a deploy script reading `$?` took a run
621+
// that applied nothing for an applied one. An operator who answers `n`
622+
// at the prompt below declined on purpose: that path keeps exit 0.
615623
if (!flags.yes) {
616624
if (flags.json || !process.stdin.isTTY) {
617-
if (flags.json) { await emitJson({ ...target, applied: [], skipped: drift, pending, message: 'confirmation_required', hint: 'pass --yes' }, 0, { compact: true }); return; }
625+
if (flags.json) { await emitJson({ ...target, applied: [], skipped: drift, pending, message: 'confirmation_required', hint: 'pass --yes' }, 1, { compact: true }); return; }
618626
printWarning('Confirmation required. Re-run with --yes to apply, or use "os migrate plan" to preview.');
627+
this.exit(1);
619628
return;
620629
}
621630
const targets = stack.telemetryDatabase !== null

0 commit comments

Comments
 (0)