-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Add state check to config entry setup to ensure it cannot be setup twice #117193
Conversation
The config entry manager had a check to make sure the state was in the NOT_LOADED state, but since the entry can retry setup we should check in the entry async_setup to verify that the entry is not already loaded or in the progress of setting up before allowing setup to proceed
all good after many restarts |
thanks |
I assume this can be added to the next milestone? |
): | ||
raise OperationNotAllowed( | ||
f"The config entry {self.title} ({self.domain}) with entry_id" | ||
f" {self.entry_id} cannot be setup because is already loaded in the" |
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.
nit:
f" {self.entry_id} cannot be setup because is already loaded in the" | |
f" {self.entry_id} cannot be set up because is already loaded in the" |
Taking another look, maybe also:
f" {self.entry_id} cannot be setup because is already loaded in the" | |
f" {self.entry_id} cannot be set up because it is already loaded in the" |
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.
I'll do a followup as I copied the message from the other location
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.
I'm adding a lock check to async_setup and async_unload to ensure we never run them without the lock in #117214. I fixed the text there
I'm a little nervous about back porting it since it changes the failure mode a bit but it's probably ok |
Proposed change
The config entry manager has a check to make sure the config entry state was in the
NOT_LOADED
state, but since the entry can retry setup and does no go through the manager, we should check in the entryasync_setup
to verify that the entry is not already loaded or in the progress of setting up before allowing setup to proceedType 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
..coveragerc
.To help with the load of incoming pull requests: