From 42f93d01769a45042f5a80a48f07fb02c90d2cce Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Tue, 23 Sep 2025 11:07:38 -0400 Subject: [PATCH] Remove message_template field from errors (#6205) --- supervisor/api/utils.py | 3 --- supervisor/const.py | 1 - tests/api/test_store.py | 31 +++++++++++-------------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/supervisor/api/utils.py b/supervisor/api/utils.py index 781bb698a..637d4933a 100644 --- a/supervisor/api/utils.py +++ b/supervisor/api/utils.py @@ -20,7 +20,6 @@ from ..const import ( JSON_EXTRA_FIELDS, JSON_JOB_ID, JSON_MESSAGE, - JSON_MESSAGE_TEMPLATE, JSON_RESULT, REQUEST_FROM, RESULT_ERROR, @@ -170,8 +169,6 @@ def api_return_error( result[JSON_JOB_ID] = job_id if error and error.error_key: result[JSON_ERROR_KEY] = error.error_key - if error and error.message_template: - result[JSON_MESSAGE_TEMPLATE] = error.message_template if error and error.extra_fields: result[JSON_EXTRA_FIELDS] = error.extra_fields diff --git a/supervisor/const.py b/supervisor/const.py index 10a53683e..b53e928f4 100644 --- a/supervisor/const.py +++ b/supervisor/const.py @@ -77,7 +77,6 @@ JSON_MESSAGE = "message" JSON_RESULT = "result" JSON_JOB_ID = "job_id" JSON_ERROR_KEY = "error_key" -JSON_MESSAGE_TEMPLATE = "message_template" JSON_EXTRA_FIELDS = "extra_fields" RESULT_ERROR = "error" diff --git a/tests/api/test_store.py b/tests/api/test_store.py index f35be6d50..8fcd8bbe2 100644 --- a/tests/api/test_store.py +++ b/tests/api/test_store.py @@ -554,16 +554,13 @@ async def test_api_store_addons_addon_availability_arch_not_supported( assert resp.status == 400 result = await resp.json() assert result["error_key"] == "addon_not_supported_architecture_error" - assert ( - result["message_template"] - == "Add-on {slug} not supported on this platform, supported architectures: {architectures}" - ) assert result["extra_fields"] == { "slug": "test_arch_addon", - "architectures": ", ".join(supported_architectures), + "architectures": (architectures := ", ".join(supported_architectures)), } - assert result["message"] == result["message_template"].format( - **result["extra_fields"] + assert ( + result["message"] + == f"Add-on test_arch_addon not supported on this platform, supported architectures: {architectures}" ) @@ -620,16 +617,13 @@ async def test_api_store_addons_addon_availability_machine_not_supported( assert resp.status == 400 result = await resp.json() assert result["error_key"] == "addon_not_supported_machine_type_error" - assert ( - result["message_template"] - == "Add-on {slug} not supported on this machine, supported machine types: {machine_types}" - ) assert result["extra_fields"] == { "slug": "test_machine_addon", - "machine_types": ", ".join(supported_machines), + "machine_types": (machine_types := ", ".join(supported_machines)), } - assert result["message"] == result["message_template"].format( - **result["extra_fields"] + assert ( + result["message"] + == f"Add-on test_machine_addon not supported on this machine, supported machine types: {machine_types}" ) @@ -683,16 +677,13 @@ async def test_api_store_addons_addon_availability_homeassistant_version_too_old assert resp.status == 400 result = await resp.json() assert result["error_key"] == "addon_not_supported_home_assistant_version_error" - assert ( - result["message_template"] - == "Add-on {slug} not supported on this system, requires Home Assistant version {version} or greater" - ) assert result["extra_fields"] == { "slug": "test_version_addon", "version": "2023.1.1", } - assert result["message"] == result["message_template"].format( - **result["extra_fields"] + assert ( + result["message"] + == "Add-on test_version_addon not supported on this system, requires Home Assistant version 2023.1.1 or greater" )