From cc5eda76d3c092062e5b1c33663eced2771e0d33 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Wed, 8 Nov 2023 10:15:27 +0100 Subject: [PATCH] Humanize core config errors in check_config helper (#103635) --- homeassistant/helpers/check_config.py | 4 +++- tests/helpers/test_check_config.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/homeassistant/helpers/check_config.py b/homeassistant/helpers/check_config.py index 64e57b09d59..f65cd4e359e 100644 --- a/homeassistant/helpers/check_config.py +++ b/homeassistant/helpers/check_config.py @@ -151,7 +151,9 @@ async def async_check_ha_config_file( # noqa: C901 core_config = CORE_CONFIG_SCHEMA(core_config) result[CONF_CORE] = core_config except vol.Invalid as err: - result.add_error(err, CONF_CORE, core_config) + result.add_error( + _format_config_error(err, CONF_CORE, core_config)[0], CONF_CORE, core_config + ) core_config = {} # Merge packages diff --git a/tests/helpers/test_check_config.py b/tests/helpers/test_check_config.py index 73d6433315e..197fb88695f 100644 --- a/tests/helpers/test_check_config.py +++ b/tests/helpers/test_check_config.py @@ -73,7 +73,11 @@ async def test_bad_core_config(hass: HomeAssistant) -> None: log_ha_config(res) error = CheckConfigError( - "not a valid value for dictionary value @ data['unit_system']", + ( + "Invalid config for [homeassistant]: not a valid value for dictionary " + "value @ data['unit_system']. Got 'bad'. (See " + f"{hass.config.path(YAML_CONFIG_FILE)}, line 2). " + ), "homeassistant", {"unit_system": "bad"}, )