Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error handling to hassio issues #94951

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion homeassistant/components/hassio/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ async def setup(self) -> None:

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])

Expand Down
18 changes: 18 additions & 0 deletions tests/components/hassio/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -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