Skip to content

Commit

Permalink
fix: return "messages" instead "incompatibilities" from compatibility…
Browse files Browse the repository at this point in the history
… API

For Confluent Schema Registry client compatibility the response field
is changed from "incompatibilities: str" to "messages: list[str]".
  • Loading branch information
jjaakola-aiven committed Oct 16, 2024
1 parent f9f5fe7 commit 951780e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/karapace/schema_registry_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_schema_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 951780e

Please sign in to comment.