From a402555a7cf9b21b519bd2997f7924d1f0ff873b Mon Sep 17 00:00:00 2001 From: William Bezuidenhout Date: Tue, 5 May 2026 14:35:29 +0200 Subject: [PATCH] fix: still exit with non-zero when there is an unknown err --- cmd/src/run_migration_compat.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/src/run_migration_compat.go b/cmd/src/run_migration_compat.go index 52baca0fc5..b27b04f0ac 100644 --- a/cmd/src/run_migration_compat.go +++ b/cmd/src/run_migration_compat.go @@ -66,19 +66,24 @@ func runMigrated() (int, error) { ctx := context.Background() err := migratedRootCommand().Run(ctx, os.Args) - if errors.HasType[*cmderrors.UsageError](err) { - return 2, nil - } - if e, ok := err.(*cmderrors.ExitCodeError); ok { - if e.HasError() { - return e.Code(), e + if err != nil { + if errors.HasType[*cmderrors.UsageError](err) { + return 2, nil } - return e.Code(), nil - } - var exitErr cli.ExitCoder - if errors.AsInterface(err, &exitErr) { - return exitErr.ExitCode(), err + if e, ok := err.(*cmderrors.ExitCodeError); ok { + if e.HasError() { + return e.Code(), e + } + return e.Code(), nil + } + var exitErr cli.ExitCoder + if errors.AsInterface(err, &exitErr) { + return exitErr.ExitCode(), err + } + + return 1, err } + return 0, err }