Exclude access token from host info updates in Konnected config flow#33912
Merged
MartinHjelmare merged 2 commits intohome-assistant:devfrom Apr 9, 2020
Merged
Exclude access token from host info updates in Konnected config flow#33912MartinHjelmare merged 2 commits intohome-assistant:devfrom
MartinHjelmare merged 2 commits intohome-assistant:devfrom
Conversation
|
Hey there @heythisisnate, mind taking a look at this pull request as its been labeled with a integration ( |
Contributor
Author
|
If another 0.108 build is released this would be a great fix to include. |
balloob
pushed a commit
that referenced
this pull request
Apr 10, 2020
…33912) * black updates * test that host update doesn't impact access token
Merged
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
In the Konnected config flow we want to automatically update the host info for a konnected config entry if SSDP indicates it changed. When updating host info we were also including a randomly generated access token in the self.data object passed to
self._abort_if_unique_id_configured(updates=self.data). This was causing config entry updates even though the host info did not change.In most cases this is fine as the config entry gets reloaded and the new access token is sent to the panel. However a race condition can occur where the reload is called after the konnected component is loaded, but before it's platforms are not yet loaded. Causing this error
When this happens the reload fails such that the panel is using the old access token but the config_entry contains the new access token. This effectively blocks any updates from the panel until the config_entry is reloaded (via a restart or manually via the integrations UI) and sends the updated settings to the panel.
This PR defers creation of the access_token during the konnected config flow so that it is not included as part of the host info changes. This prevents the panels from being orphaned if host info changes and also prevents the unnecessary config entry updates stemming from the changed access token.
Type of change
Additional information
Checklist
black --fast 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..coveragerc.The integration reached or maintains the following Integration Quality Scale: