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:
|
) -> None:
|
||||||
"""Create a repair issue."""
|
"""Create a repair issue."""
|
||||||
if translation_key not in VALID_REPAIR_TRANSLATION_KEYS:
|
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(
|
async_create_issue(
|
||||||
hass=self._hass,
|
hass=self._hass,
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
|
@ -482,19 +482,20 @@ async def test_async_create_repair_issue_unknown(
|
|||||||
cloud: MagicMock,
|
cloud: MagicMock,
|
||||||
mock_cloud_setup: None,
|
mock_cloud_setup: None,
|
||||||
issue_registry: ir.IssueRegistry,
|
issue_registry: ir.IssueRegistry,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test not creating repair issue for unknown repairs."""
|
"""Test not creating repair issue for unknown repairs."""
|
||||||
identifier = "abc123"
|
identifier = "abc123"
|
||||||
with pytest.raises(
|
await cloud.client.async_create_repair_issue(
|
||||||
ValueError,
|
identifier=identifier,
|
||||||
match="Invalid translation key unknown_translation_key",
|
translation_key="unknown_translation_key",
|
||||||
):
|
placeholders={"custom_domains": "example.com"},
|
||||||
await cloud.client.async_create_repair_issue(
|
severity="error",
|
||||||
identifier=identifier,
|
)
|
||||||
translation_key="unknown_translation_key",
|
assert (
|
||||||
placeholders={"custom_domains": "example.com"},
|
"Invalid translation key unknown_translation_key for repair issue abc123"
|
||||||
severity="error",
|
in caplog.text
|
||||||
)
|
)
|
||||||
issue = issue_registry.async_get_issue(domain=DOMAIN, issue_id=identifier)
|
issue = issue_registry.async_get_issue(domain=DOMAIN, issue_id=identifier)
|
||||||
assert issue is None
|
assert issue is None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user