Fix Duco diagnostics crash on connection error#169322
Merged
erwindouna merged 3 commits intoApr 28, 2026
Merged
Conversation
b6ce185 to
32d8b37
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Duco diagnostics downloads failing with an unhandled connection exception when the device is offline, by converting connection failures into a Home Assistant–native exception and adding a regression test.
Changes:
- Catch
DucoConnectionErrorduring diagnostics retrieval and raiseHomeAssistantErrorinstead. - Add a translatable exception message for diagnostics connection failures.
- Add a test that verifies a diagnostics request returns an HTTP 500 when any of the underlying diagnostics API calls fails with a connection error.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
homeassistant/components/duco/diagnostics.py |
Adds connection-error handling around diagnostics API calls. |
homeassistant/components/duco/strings.json |
Adds a new translated exception message for diagnostics connection failures. |
tests/components/duco/test_diagnostics.py |
Adds a regression test for connection errors during diagnostics download. |
erwindouna
requested changes
Apr 27, 2026
Member
erwindouna
left a comment
There was a problem hiding this comment.
Good fix. Just a few points for discussion or patching. :)
Contributor
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
erwindouna
approved these changes
Apr 28, 2026
Member
erwindouna
left a comment
There was a problem hiding this comment.
Looks good to me, thanks @ronaldvdmeer!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
The Duco diagnostics platform crashed with an unhandled
DucoConnectionErrorwhen the device was unreachable during a diagnostics download. The exception propagated all the way up instead of returning a meaningful error to the user.This PR wraps each API call in
async_get_config_entry_diagnosticswith a try/except that catchesDucoConnectionErrorand raisesHomeAssistantError, which Home Assistant handles gracefully.Important
This fixes a crash in the diagnostics platform when the device is temporarily offline.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.