mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
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:
parent
2266e97417
commit
da0d65ca5b
@ -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,
|
||||
|
@ -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",
|
||||
)
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user