Skip to content

Commit

Permalink
Fix error message formatting variable expansion
Browse files Browse the repository at this point in the history
Fix formatting of error message variable expansion if subject level
compatibility mode is not configured.
  • Loading branch information
tvainika committed Apr 17, 2024
1 parent aafc087 commit b876472
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion karapace/schema_registry_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class SchemaErrorMessages(Enum):
"forward, full, backward_transitive, forward_transitive, and "
"full_transitive"
)
SUBJECT_LEVEL_COMPATIBILITY_NOT_CONFIGURED_FMT = "Subject '%s' does not have subject-level compatibility configured"
SUBJECT_LEVEL_COMPATIBILITY_NOT_CONFIGURED_FMT = (
"Subject '{subject}' does not have subject-level compatibility configured"
)
REFERENCES_SUPPORT_NOT_IMPLEMENTED = "Schema references are not supported for '{schema_type}' schema type"


Expand Down
8 changes: 2 additions & 6 deletions tests/integration/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2103,9 +2103,7 @@ async def test_config(registry_async_client: Client, trail: str) -> None:
res = await registry_async_client.get(f"config/{subject_1}{trail}")
assert res.status_code == 404
assert res.json()["error_code"] == 40408
assert res.json()["message"] == SchemaErrorMessages.SUBJECT_LEVEL_COMPATIBILITY_NOT_CONFIGURED_FMT.value.format(
subject=subject_1
)
assert res.json()["message"] == f"Subject '{subject_1}' does not have subject-level compatibility configured"

res = await registry_async_client.put(f"config/{subject_1}{trail}", json={"compatibility": "FULL"})
assert res.status_code == 200
Expand All @@ -2125,9 +2123,7 @@ async def test_config(registry_async_client: Client, trail: str) -> None:
res = await registry_async_client.get(f"config/{subject_1}{trail}")
assert res.status_code == 404
assert res.json()["error_code"] == 40408
assert res.json()["message"] == SchemaErrorMessages.SUBJECT_LEVEL_COMPATIBILITY_NOT_CONFIGURED_FMT.value.format(
subject=subject_1
)
assert res.json()["message"] == f"Subject '{subject_1}' does not have subject-level compatibility configured"

# It's possible to add a config to a subject that doesn't exist yet
subject_2 = subject_name_factory()
Expand Down

0 comments on commit b876472

Please sign in to comment.