-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
Display error when forming new ZHA network fails #157863
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
Display error when forming new ZHA network fails #157863
Conversation
|
Hey there @dmulcahey, @Adminiuga, @puddly, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds error handling for ZHA network formation failures in the config flow. Previously, when network formation failed, the UI spinner would spin endlessly without providing any user feedback. Now, all exceptions during network formation are caught and displayed to the user with a clear error message.
Key Changes
- Added broad exception handling in
async_step_form_new_networkto catch all network formation failures - User-facing error messages displayed via the abort flow mechanism with specific error details
- Comprehensive test coverage for the network formation failure scenario
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| homeassistant/components/zha/config_flow.py | Added try-except block to catch and handle network formation exceptions, setting progress error and returning progress_failed step |
| homeassistant/components/zha/strings.json | Added "cannot_form_network" abort reason with error placeholder for both config and options flows |
| tests/components/zha/test_config_flow.py | Added test case verifying proper error handling when network formation fails with an exception |
Proposed change
This broadly catches all exceptions when ZHA network formation fails, displays a user-facing error message, and logs further detail. Before this PR, the UI spinner for the config flow progress task would spin endlessly, providing no feedback.
Example error message:

We want to broadly catch all exceptions for now, as there's an issue in HA Core where unexpected exceptions (in config flows progress tasks) are swallowed due to an underlying issue. Related PRs for that:
Background
We're seeing multiple people run into an issue where ZHA network formation fails for some unknown reason, causing them to end up with an endless spinner. Due to the Core issue, there's nothing in the logs about the error. Related issues:
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.To help with the load of incoming pull requests: