diff --git a/src/karapace/schema_registry_apis.py b/src/karapace/schema_registry_apis.py index a37a3ff9f..61a935e0c 100644 --- a/src/karapace/schema_registry_apis.py +++ b/src/karapace/schema_registry_apis.py @@ -412,8 +412,8 @@ async def compatibility_check( result = SchemaCompatibility.check_compatibility(old_schema, new_schema, compatibility_mode) if is_incompatible(result): - maybe_truncated_error = ", ".join(result.messages)[:300] - self.r({"is_compatible": False, "incompatibilities": maybe_truncated_error}, content_type) + maybe_truncated_errors = [message[:300] for message in result.messages] + self.r({"is_compatible": False, "messages": maybe_truncated_errors}, content_type) self.r({"is_compatible": True}, content_type) async def schemas_list(self, content_type: str, *, request: HTTPRequest, user: User | None = None): diff --git a/tests/integration/test_schema_compatibility.py b/tests/integration/test_schema_compatibility.py index 82228ba32..7d3cbc280 100644 --- a/tests/integration/test_schema_compatibility.py +++ b/tests/integration/test_schema_compatibility.py @@ -44,7 +44,7 @@ class SchemaCompatibilityTestCase(BaseTestCase): register_baseline_schemas: SchemaRegitrationFunc expected_is_compatible: bool | None expected_status_code: int - expected_incompatibilities: str | None + expected_incompatibilities: list[str] | None async def _register_baseline_schemas_no_incompatibilities(registry_async_client: Client, subject: Subject) -> None: @@ -149,7 +149,7 @@ async def _set_compatibility_mode(registry_async_client: Client, subject: Subjec new_schema=json.dumps(schema_int), expected_is_compatible=False, expected_status_code=200, - expected_incompatibilities="reader type: int not compatible with writer type: double", + expected_incompatibilities=["reader type: int not compatible with writer type: double"], ), # Case 3 # Same as previous case, but in non-transitive mode @@ -161,7 +161,7 @@ async def _set_compatibility_mode(registry_async_client: Client, subject: Subjec new_schema=json.dumps(schema_int), expected_is_compatible=False, expected_status_code=200, - expected_incompatibilities="reader type: int not compatible with writer type: string", + expected_incompatibilities=["reader type: int not compatible with writer type: string"], ), # Case 4 # Same as case 2, but with a deleted schema among baseline ones @@ -175,7 +175,7 @@ async def _set_compatibility_mode(registry_async_client: Client, subject: Subjec new_schema=json.dumps(schema_int), expected_is_compatible=False, expected_status_code=200, - expected_incompatibilities="reader type: int not compatible with writer type: double", + expected_incompatibilities=["reader type: int not compatible with writer type: double"], ), # Case 5 # Same as case 3, but with a deleted schema among baseline ones @@ -188,7 +188,7 @@ async def _set_compatibility_mode(registry_async_client: Client, subject: Subjec new_schema=json.dumps(schema_int), expected_is_compatible=False, expected_status_code=200, - expected_incompatibilities="reader type: int not compatible with writer type: string", + expected_incompatibilities=["reader type: int not compatible with writer type: string"], ), # Case 6 # A new schema and no baseline schemas @@ -232,4 +232,4 @@ async def test_schema_compatibility(test_case: SchemaCompatibilityTestCase, regi assert res.status_code == test_case.expected_status_code assert res.json().get("is_compatible") == test_case.expected_is_compatible - assert res.json().get("incompatibilities", None) == test_case.expected_incompatibilities + assert res.json().get("messages", None) == test_case.expected_incompatibilities