Skip to content

Commit f2ca5a4

Browse files
committed
Properly raise repo import errors instead of catching them
Fixes #4334
1 parent 5de9bfd commit f2ca5a4

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

backend/infrahub/git/integrator.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ async def import_schema_files(self, branch_name: str, commit: str, config_file:
448448
await self.log.warning(
449449
f"Unable to find the schema {schema}", repository=self.name, branch=branch_name, commit=commit
450450
)
451-
continue
452451

453452
if full_schema.is_file():
454453
schema_file = SchemaFile(identifier=str(schema), location=full_schema)
@@ -464,7 +463,6 @@ async def import_schema_files(self, branch_name: str, commit: str, config_file:
464463
schema_file.load_content()
465464
schemas_data.append(schema_file)
466465

467-
has_error = False
468466
for schema_file in schemas_data:
469467
if schema_file.valid:
470468
continue
@@ -474,10 +472,6 @@ async def import_schema_files(self, branch_name: str, commit: str, config_file:
474472
branch=branch_name,
475473
commit=commit,
476474
)
477-
has_error = True
478-
479-
if has_error:
480-
return
481475

482476
# Valid data format of content
483477
for schema_file in schemas_data:
@@ -490,10 +484,10 @@ async def import_schema_files(self, branch_name: str, commit: str, config_file:
490484
branch=branch_name,
491485
commit=commit,
492486
)
493-
has_error = True
494-
495-
if has_error:
496-
return
487+
raise ValidationError(
488+
identifier=str(self.id),
489+
message=f"Schema not valid, found '{len(exc.errors())}' error(s) in {schema_file.identifier} : {exc}",
490+
) from exc
497491

498492
response = await self.sdk.schema.load(schemas=[item.content for item in schemas_data], branch=branch_name)
499493

@@ -513,7 +507,9 @@ async def import_schema_files(self, branch_name: str, commit: str, config_file:
513507
f"Unable to load the schema : {', '.join(error_messages)}", repository=self.name, commit=commit
514508
)
515509

516-
return
510+
raise ValidationError(
511+
identifier=str(self.id), message=f"Unable to load the schema : {', '.join(error_messages)}"
512+
)
517513

518514
for schema_file in schemas_data:
519515
await self.log.info(
@@ -618,7 +614,7 @@ async def import_python_check_definitions(
618614
await self.log.warning(
619615
self.name, import_type="check_definition", file=check.file_path.as_posix(), error=str(exc)
620616
)
621-
continue
617+
raise
622618

623619
checks.extend(
624620
await self.get_check_definition(
@@ -803,7 +799,7 @@ async def import_python_transforms(
803799
await self.log.warning(
804800
self.name, import_type="python_transform", file=transform.file_path.as_posix(), error=str(exc)
805801
)
806-
continue
802+
raise
807803

808804
transforms.extend(
809805
await self.get_python_transforms(
@@ -899,6 +895,7 @@ async def get_check_definition(
899895
repository=self.name,
900896
branch=branch_name,
901897
)
898+
raise
902899
return checks
903900

904901
async def get_python_transforms(
@@ -931,6 +928,7 @@ async def get_python_transforms(
931928
repository=self.name,
932929
branch=branch_name,
933930
)
931+
raise
934932

935933
return transforms
936934

changelog/4334.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Properly raise errors instead of just logging them during repository import failures so that the "sync status" gets updated even if we've caught the errors.

0 commit comments

Comments
 (0)