mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 04:08:19 -04:00
Fix automation setup failing on a null key in a YAML automation (#194740)
This commit is contained in:
@@ -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
|
||||
]
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user