-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Prevent async_create_entry
from reauth/reconfigure flows
#127527
base: dev
Are you sure you want to change the base?
Conversation
homeassistant/config_entries.py
Outdated
"Detected %s config flow using `async_create_entry`, which " | ||
"can cause unexpected behavior and will stop working in %s. " |
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 think we should not say "can cause unexpected behavior", I think we should say we want reconfigure and reauth flows to update an existing entry and then abort, not create a new entry.
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.
Message updated
We should update developer documentation to explain reconfigure and reauth flows are expected to update an existing entry and then abort: |
I created a docs PR home-assistant/developers.home-assistant#2352 I have also adjusted the error message and the PR description. |
Breaking change
Use of
async_create_entry
within reauth and reconfigure flow causes new config entries to be created.If an existing entry exists with the same unique_id, it will also cause the previous entry to be removed.
This invalid use of
async_create_entry
will be blocked from2025.11
.Please refactor to use
async_update_reload_and_abort
orasync_abort
with a valid reason (eg.reauth_successful
,reconfigure_successful
, ...)Proposed change
Tests have been added to highlight the behavior.
Sample run raising
ValueError
on core: https://github.com/home-assistant/core/actions/runs/11176114641Violations fixed in:
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: