From 60b78f46486ba420cc4ed7419f6557d3b678c91e Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:17:11 +0200 Subject: [PATCH] Add error handling to hassio issues (#94951) --- homeassistant/components/hassio/issues.py | 6 +++++- tests/components/hassio/test_issues.py | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/hassio/issues.py b/homeassistant/components/hassio/issues.py index 2af0a6ed764..0bbd89aab86 100644 --- a/homeassistant/components/hassio/issues.py +++ b/homeassistant/components/hassio/issues.py @@ -306,7 +306,11 @@ class SupervisorIssues: async def update(self) -> None: """Update issues from Supervisor resolution center.""" - data = await self._client.get_resolution_info() + try: + data = await self._client.get_resolution_info() + except HassioAPIError as err: + _LOGGER.error("Failed to update supervisor issues: %r", err) + return self.unhealthy_reasons = set(data[ATTR_UNHEALTHY]) self.unsupported_reasons = set(data[ATTR_UNSUPPORTED]) diff --git a/tests/components/hassio/test_issues.py b/tests/components/hassio/test_issues.py index 7bd30e452c0..4d694b79e46 100644 --- a/tests/components/hassio/test_issues.py +++ b/tests/components/hassio/test_issues.py @@ -715,3 +715,21 @@ async def test_supervisor_remove_missing_issue_without_error( msg = await client.receive_json() assert msg["success"] await hass.async_block_till_done() + + +async def test_system_is_not_ready( + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + caplog: pytest.LogCaptureFixture, +) -> None: + """Ensure hassio starts despite error.""" + aioclient_mock.get( + "http://127.0.0.1/resolution/info", + json={ + "result": "", + "message": "System is not ready with state: setup", + }, + ) + + assert await async_setup_component(hass, "hassio", {}) + assert "Failed to update supervisor issues" in caplog.text