Log instead of ValueError for missing cloud translation key (#144732)

* Log instead of ValueError for missing translation key

* Update homeassistant/components/cloud/client.py
This commit is contained in:
Joakim Sørensen 2025-05-12 18:59:38 +02:00 committed by GitHub
parent 2266e97417
commit da0d65ca5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 11 deletions

View File

@ -404,7 +404,12 @@ class CloudClient(Interface):
) -> None:
"""Create a repair issue."""
if translation_key not in VALID_REPAIR_TRANSLATION_KEYS:
raise ValueError(f"Invalid translation key {translation_key}")
_LOGGER.error(
"Invalid translation key %s for repair issue %s",
translation_key,
identifier,
)
return
async_create_issue(
hass=self._hass,
domain=DOMAIN,

View File

@ -482,19 +482,20 @@ async def test_async_create_repair_issue_unknown(
cloud: MagicMock,
mock_cloud_setup: None,
issue_registry: ir.IssueRegistry,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test not creating repair issue for unknown repairs."""
identifier = "abc123"
with pytest.raises(
ValueError,
match="Invalid translation key unknown_translation_key",
):
await cloud.client.async_create_repair_issue(
identifier=identifier,
translation_key="unknown_translation_key",
placeholders={"custom_domains": "example.com"},
severity="error",
)
assert (
"Invalid translation key unknown_translation_key for repair issue abc123"
in caplog.text
)
issue = issue_registry.async_get_issue(domain=DOMAIN, issue_id=identifier)
assert issue is None