diff --git a/homeassistant/components/automation/config.py b/homeassistant/components/automation/config.py index b1621c45c789..8e8287276d4b 100644 --- a/homeassistant/components/automation/config.py +++ b/homeassistant/components/automation/config.py @@ -383,8 +383,10 @@ async def _async_collect_located_errors( # Keep the error if validating again does not give any errors = await _async_collect_errors(hass, config) or fail_fast_errors return [ - ValidationErrorInfo(info.exception, (_RENAMED_KEYS[path[0]], *path[1:])) - if (path := info.path) and _RENAMED_KEYS.get(path[0]) in submitted_keys + ValidationErrorInfo(info.exception, (old_key, *path[1:])) + if (path := info.path) + and (old_key := _RENAMED_KEYS.get(path[0])) is not None + and old_key in submitted_keys else info for info in errors ] diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index d6869022409c..d2308512d65b 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -2005,6 +2005,19 @@ def _error_messages(caplog: pytest.LogCaptureFixture) -> list[str]: " 'actions': [{'not_an_action': 1}]}", "validation_failed_schema", ), + ( + # A null key, which YAML gives for `~:`, next to a renamed key + { + None: "oops", + "trigger": {"trigger": "not_a_platform"}, + "actions": [], + }, + "could not be validated", + "not a valid option at '[None]'. Got 'oops'\n" + "Invalid trigger 'not_a_platform' specified at 'trigger'." + " Got {'trigger': 'not_a_platform'}", + "validation_failed_schema", + ), ], ) async def test_automation_bad_config_validation(