Skip to content

Commit 9acaf5d

Browse files
committed
Catch migration failure exception to update CLI feedback
1 parent 3a5c1cd commit 9acaf5d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

backend/infrahub/cli/db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
GraphRelationshipProperties,
3737
)
3838
from infrahub.core.initialization import get_root_node, initialize_registry
39+
from infrahub.core.migrations.exceptions import MigrationFailureError
3940
from infrahub.core.migrations.graph import get_graph_migrations, get_migration_by_number
4041
from infrahub.core.migrations.schema.models import SchemaApplyMigrationData
4142
from infrahub.core.migrations.schema.tasks import schema_apply_migrations
@@ -384,7 +385,7 @@ async def trigger_rebase_branches(db: InfrahubDatabase) -> None:
384385
send_events=False,
385386
)
386387
rprint(SUCCESS_BADGE)
387-
except ValidationError:
388+
except (ValidationError, MigrationFailureError):
388389
rprint(FAILED_BADGE)
389390

390391

backend/infrahub/core/branch/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def migrate_branch(branch: str, context: InfrahubContext, send_events: boo
8989
await migration_runner.run(db=db)
9090
except MigrationFailureError as exc:
9191
log.error(f"Failed to run migrations for branch '{obj.name}': {exc.errors}")
92-
return
92+
raise
9393

9494
if obj.status == BranchStatus.NEED_UPGRADE_REBASE:
9595
obj.status = BranchStatus.OPEN

0 commit comments

Comments
 (0)