Catch HomeAssistantError in ZHA migration retry loops#168420
Catch HomeAssistantError in ZHA migration retry loops#168420TheJulianJES merged 1 commit intodevfrom
Conversation
The retry loops in async_initiate_migration (backup) and async_finish_migration (restore) only caught OSError, but connection failures can also surface as HomeAssistantError (e.g. wrapping a TimeoutError). Include it in both retries so transient connection issues are retried instead of aborting the migration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey there @dmulcahey, @Adminiuga, @puddly, @TheJulianJES, 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.
Pull request overview
Update ZHA multi-PAN migration retry loops to also retry when transient connection failures are surfaced as HomeAssistantError, preventing migrations from aborting prematurely.
Changes:
- Catch
HomeAssistantErroralongsideOSErrorwhen creating a backup inasync_initiate_migration. - Catch
HomeAssistantErroralongsideOSErrorwhen restoring a backup inasync_finish_migration.
| ) | ||
| break | ||
| except OSError as err: | ||
| except (OSError, HomeAssistantError) as err: |
There was a problem hiding this comment.
Add a regression test that verifies HomeAssistantError is retried (and eventually re-raised) during backup creation, since the retry loop now explicitly catches it alongside OSError.
There was a problem hiding this comment.
It's only relevant for migrating to and from multi-PAN, which is no longer supported. I'm guessing we'll remove this migration soon/eventually, so not a big need to test this.
| await self._radio_mgr.restore_backup(overwrite_ieee=True) | ||
| break | ||
| except OSError as err: | ||
| except (OSError, HomeAssistantError) as err: |
There was a problem hiding this comment.
Add a regression test that verifies HomeAssistantError is retried (and eventually re-raised) during backup restore, since the retry loop now explicitly catches it alongside OSError.
puddly
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks!
TheJulianJES
left a comment
There was a problem hiding this comment.
Thanks! Just curious because this is only relevant for migrating to and from the old multi-PAN stuff, did you run into this yourself or saw a report about it?
Run into it myself while testing #168431. |
Breaking change
Proposed change
The retry loops in
async_initiate_migration(backup) andasync_finish_migration(restore) only caught OSError, but connection failures can also surface asHomeAssistantError(e.g. wrapping aTimeoutError). Include it in both retries so transient connection issues are retried instead of aborting the migration.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: