Map asyncssh connect-call OS errors to user-facing validation errors - #51
Merged
gensyn merged 4 commits intoSep 1, 2026
Merged
Conversation
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
gensyn
September 1, 2026 08:16
View session
gensyn
marked this pull request as ready for review
September 1, 2026 08:19
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The newly added tests hard-code errno 101, which is platform-dependent; using ENETUNREACH (and/or EHOSTUNREACH) constants will make the coverage robust.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves ssh_command.execute error handling by converting specific transport-layer OSError failures from asyncssh.connect() (network/host unreachable) into a user-facing ServiceValidationError with the existing host_not_reachable translation key, and adds test coverage for that mapping.
Changes:
- Map
OSErrorwitherrnoin(ENETUNREACH, EHOSTUNREACH)toServiceValidationError(..., translation_key="host_not_reachable")(in addition to existingsocket.gaierrorhandling). - Add unit test coverage for the new unreachable-network mapping.
- Add integration test coverage for the same mapping through the Home Assistant service call boundary.
File summaries
| File | Description |
|---|---|
| coordinator.py | Extends OSError handling to map unreachable network/host errors to host_not_reachable. |
| tests/unit_tests/test_coordinator.py | Adds a unit test asserting translation key mapping for unreachable-network OSError. |
| tests/integration_tests/test_integration.py | Adds an integration test asserting translation key mapping for unreachable-network OSError via service call. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
gensyn
deleted the
copilot/catch-generic-error-and-present-friendly-message
branch
September 1, 2026 08:38
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ssh_command.executesurfaced low-level asyncssh/socket tracebacks for failed TCP connects (e.g.OSError: [Errno 101] Connect call failed (...)), which appeared to users as generic script failures. This change maps those transport-level reachability errors into existing localized service errors.Error handling (runtime behavior)
SshCommandCoordinator.async_execute()OSErrorhandling to treat unreachable-network host errors ashost_not_reachable.errnovaluesENETUNREACHandEHOSTUNREACH(in addition to existingsocket.gaierror) toServiceValidationErrorwith translation keyhost_not_reachable.Coverage updates
OSError(101, "Connect call failed ...")to verify translation key mapping.