-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add a blog post about improved error handling for oauth2 configuration without internet #2850
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
Merged
MartinHjelmare
merged 3 commits into
home-assistant:master
from
wmoss:blog-2025-10-26-config-entry-aouth2-error-handling
Nov 5, 2025
+23
−0
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| author: Will Moss | ||
| authorURL: https://github.com/wmoss | ||
| title: "Improved error handling for oauth2 configuration without internet" | ||
| --- | ||
|
|
||
| Integrations using [Application Credentials](https://developers.home-assistant.io/docs/core/platform/application_credentials/) and [Configuration via OAuth2](https://developers.home-assistant.io/docs/config_entries_config_flow_handler/#configuration-via-oauth2) need to update their error handling to correctly handle configuration when the internet is down. | ||
|
|
||
| Currently integrations using configuration via OAuth2 call `config_entry_oauth2_flow.async_get_config_entry_implementation` in `async_setup_entry` in their `__init__.py`. Previously when there was no network, this would raise `ValueError: Implementation not available`, which was a non-retryable error, resulting in the integration needing to be manually reconfigured after internet was restored (see Issues [153956](https://github.com/home-assistant/core/issues/153956) and [144582](https://github.com/home-assistant/core/issues/144582)). [core PR 154579](https://github.com/home-assistant/core/pull/154579) added `config_entry_oauth2_flow.ImplementationUnavailableError` and raises it in `config_entry_oauth2_flow.async_get_config_entry_implementation` when OAuth2 configuration is unavailable because of missing internet. Integrations should catch this error and raise `ConfigEntryNotReady`. | ||
MartinHjelmare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Here is an example of the migration, | ||
| ```diff | ||
| - implementation = await async_get_config_entry_implementation(hass, entry) | ||
| + try: | ||
| + implementation = await async_get_config_entry_implementation(hass, entry) | ||
| + except ImplementationUnavailableError as err: | ||
| + raise ConfigEntryNotReady( | ||
| + "OAuth2 implementation temporarily unavailable, will retry" | ||
| + ) from err | ||
| ``` | ||
|
|
||
| New integrations will find the correct `try` / `except` block generated by `python3 -m script.scaffold config_flow_oauth2`. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.