Fix automation setup failing on a null key in a YAML automation (#194740)

This commit is contained in:
Artur Pragacz
2026-11-26 13:12:58 +00:00
committed by GitHub
parent a066dab21e
commit d248902f90
2 changed files with 17 additions and 2 deletions
@@ -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
]
+13
View File
@@ -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(