From f164a5a65ffebacae2ec7cbf9d39f825fcdf2a8e Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Sun, 11 Mar 2018 12:51:03 +0200 Subject: [PATCH] Better errors for unknown secrets (#13072) --- homeassistant/scripts/check_config.py | 6 +++++- homeassistant/util/yaml.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 641693501ff..1a58757d17f 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -140,6 +140,9 @@ def run(script_args: List) -> int: print(color(C_HEAD, 'Used Secrets:')) for skey, sval in res['secrets'].items(): + if sval is None: + print(' -', skey + ':', color('red', "not found")) + continue print(' -', skey + ':', sval, color('cyan', '[from:', flatsecret .get(skey, 'keyring') + ']')) @@ -308,7 +311,8 @@ def check_ha_config_file(config_dir): return result.add_error("File configuration.yaml not found.") config = load_yaml_config_file(config_path) except HomeAssistantError as err: - return result.add_error(err) + return result.add_error( + "Error loading {}: {}".format(config_path, err)) finally: yaml.clear_secret_cache() diff --git a/homeassistant/util/yaml.py b/homeassistant/util/yaml.py index 8ac8d096b99..66d673987a3 100644 --- a/homeassistant/util/yaml.py +++ b/homeassistant/util/yaml.py @@ -288,8 +288,7 @@ def _secret_yaml(loader: SafeLineLoader, # Catch if package installed and no config credstash = None - _LOGGER.error("Secret %s not defined", node.value) - raise HomeAssistantError(node.value) + raise HomeAssistantError("Secret {} not defined".format(node.value)) yaml.SafeLoader.add_constructor('!include', _include_yaml)