Skip to content

Commit 42f93d0

Browse files
authored
Remove message_template field from errors (#6205)
1 parent ed71556 commit 42f93d0

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

supervisor/api/utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
JSON_EXTRA_FIELDS,
2121
JSON_JOB_ID,
2222
JSON_MESSAGE,
23-
JSON_MESSAGE_TEMPLATE,
2423
JSON_RESULT,
2524
REQUEST_FROM,
2625
RESULT_ERROR,
@@ -170,8 +169,6 @@ def api_return_error(
170169
result[JSON_JOB_ID] = job_id
171170
if error and error.error_key:
172171
result[JSON_ERROR_KEY] = error.error_key
173-
if error and error.message_template:
174-
result[JSON_MESSAGE_TEMPLATE] = error.message_template
175172
if error and error.extra_fields:
176173
result[JSON_EXTRA_FIELDS] = error.extra_fields
177174

supervisor/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
JSON_RESULT = "result"
7878
JSON_JOB_ID = "job_id"
7979
JSON_ERROR_KEY = "error_key"
80-
JSON_MESSAGE_TEMPLATE = "message_template"
8180
JSON_EXTRA_FIELDS = "extra_fields"
8281

8382
RESULT_ERROR = "error"

tests/api/test_store.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -554,16 +554,13 @@ async def test_api_store_addons_addon_availability_arch_not_supported(
554554
assert resp.status == 400
555555
result = await resp.json()
556556
assert result["error_key"] == "addon_not_supported_architecture_error"
557-
assert (
558-
result["message_template"]
559-
== "Add-on {slug} not supported on this platform, supported architectures: {architectures}"
560-
)
561557
assert result["extra_fields"] == {
562558
"slug": "test_arch_addon",
563-
"architectures": ", ".join(supported_architectures),
559+
"architectures": (architectures := ", ".join(supported_architectures)),
564560
}
565-
assert result["message"] == result["message_template"].format(
566-
**result["extra_fields"]
561+
assert (
562+
result["message"]
563+
== f"Add-on test_arch_addon not supported on this platform, supported architectures: {architectures}"
567564
)
568565

569566

@@ -620,16 +617,13 @@ async def test_api_store_addons_addon_availability_machine_not_supported(
620617
assert resp.status == 400
621618
result = await resp.json()
622619
assert result["error_key"] == "addon_not_supported_machine_type_error"
623-
assert (
624-
result["message_template"]
625-
== "Add-on {slug} not supported on this machine, supported machine types: {machine_types}"
626-
)
627620
assert result["extra_fields"] == {
628621
"slug": "test_machine_addon",
629-
"machine_types": ", ".join(supported_machines),
622+
"machine_types": (machine_types := ", ".join(supported_machines)),
630623
}
631-
assert result["message"] == result["message_template"].format(
632-
**result["extra_fields"]
624+
assert (
625+
result["message"]
626+
== f"Add-on test_machine_addon not supported on this machine, supported machine types: {machine_types}"
633627
)
634628

635629

@@ -683,16 +677,13 @@ async def test_api_store_addons_addon_availability_homeassistant_version_too_old
683677
assert resp.status == 400
684678
result = await resp.json()
685679
assert result["error_key"] == "addon_not_supported_home_assistant_version_error"
686-
assert (
687-
result["message_template"]
688-
== "Add-on {slug} not supported on this system, requires Home Assistant version {version} or greater"
689-
)
690680
assert result["extra_fields"] == {
691681
"slug": "test_version_addon",
692682
"version": "2023.1.1",
693683
}
694-
assert result["message"] == result["message_template"].format(
695-
**result["extra_fields"]
684+
assert (
685+
result["message"]
686+
== "Add-on test_version_addon not supported on this system, requires Home Assistant version 2023.1.1 or greater"
696687
)
697688

698689

0 commit comments

Comments
 (0)