From b8764720710c630e9d4872bd56c45b4b293db504 Mon Sep 17 00:00:00 2001 From: Tommi Vainikainen Date: Wed, 17 Apr 2024 13:34:59 +0300 Subject: [PATCH] Fix error message formatting variable expansion Fix formatting of error message variable expansion if subject level compatibility mode is not configured. --- karapace/schema_registry_apis.py | 4 +++- tests/integration/test_schema.py | 8 ++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/karapace/schema_registry_apis.py b/karapace/schema_registry_apis.py index cc8aa341f..0216b5e5e 100644 --- a/karapace/schema_registry_apis.py +++ b/karapace/schema_registry_apis.py @@ -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" diff --git a/tests/integration/test_schema.py b/tests/integration/test_schema.py index 77e43bfdc..fa8d0ddae 100644 --- a/tests/integration/test_schema.py +++ b/tests/integration/test_schema.py @@ -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 @@ -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()