Skip to content

Commit cee1bf6

Browse files
authored
Merge pull request #1142 from Aiven-Open/nosahama/FLEET-5990/invalid-refs-compatibility-check
api: handle `InvalidReferences` error on compatibility check endpoint
2 parents 1e857e7 + 43429f9 commit cee1bf6

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/karapace/api/controller.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,14 @@ def get_new_schema(self, schema_request: SchemaRequest) -> ValidatedTypedSchema:
917917
"message": f"Invalid {schema_request.schema_type} schema",
918918
},
919919
) from exc
920+
except InvalidReferences as exc:
921+
raise HTTPException(
922+
status_code=status.HTTP_400_BAD_REQUEST,
923+
detail={
924+
"error_code": SchemaErrorCodes.INVALID_SCHEMA.value,
925+
"message": f"New {schema_request.schema_type} schema has invalid references",
926+
},
927+
) from exc
920928

921929
def get_old_schema(self, subject: Subject, version: Version) -> ParsedTypedSchema:
922930
old: JsonObject | None = None
@@ -949,3 +957,11 @@ def get_old_schema(self, subject: Subject, version: Version) -> ParsedTypedSchem
949957
"message": f"Found an invalid {old_schema_type} schema registered",
950958
},
951959
) from exc
960+
except InvalidReferences as exc:
961+
raise HTTPException(
962+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
963+
detail={
964+
"error_code": SchemaErrorCodes.INVALID_SCHEMA.value,
965+
"message": f"Existing {old_schema_type} schema has invalid references",
966+
},
967+
) from exc

0 commit comments

Comments
 (0)