Add check for valid error code in translation checks in flows (#128445)

This commit is contained in:
epenet
2024-10-16 19:03:24 +02:00
committed by GitHub
parent 15fc4a8ae4
commit 0bc572787a
15 changed files with 114 additions and 2 deletions

View File

@@ -540,6 +540,18 @@ def check_config_translations(ignore_translations: str | list[str]) -> Generator
# Gets set to False on first run, and to True on subsequent runs
setattr(flow, "__flow_seen_before", hasattr(flow, "__flow_seen_before"))
if result["type"] is FlowResultType.FORM:
if errors := result.get("errors"):
for error in errors.values():
await _ensure_translation_exists(
flow.hass,
_ignore_translations,
category,
component,
f"error.{error}",
)
return result
if result["type"] is FlowResultType.ABORT:
# We don't need translations for a discovery flow which immediately
# aborts, since such flows won't be seen by users