-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Abort if a flow is removed during a step #142138
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
Conversation
a3bd027
to
f52d0fb
Compare
@callback | ||
def async_flow_removed( | ||
self, | ||
flow: data_entry_flow.FlowHandler[ConfigFlowContext, ConfigFlowResult], | ||
result: ConfigFlowResult, | ||
) -> ConfigFlowResult: | ||
"""Finish a config flow and add an entry. | ||
|
||
This method is called when a flow step returns FlowResultType.ABORT or | ||
FlowResultType.CREATE_ENTRY. | ||
""" | ||
) -> None: | ||
"""Handle a removed config flow.""" |
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.
The point of this method is to unconditionally remove reauth issues when a reauth flow is removed. We could optionally also include updating of the discovery keys, but I don't think that's needed.
Latest design looks a lot cleaner. 👍 |
This needs tests of the new method and changed behavior before merge Edit: Tests have been added, I think this can be merged now. |
Thanks @emontnemery |
Proposed change
Abort early if a flow is removed during a step, instead of going ahead creating an entry
To still give flow managers the opportunity to clean up, a new method
FlowManager.async_flow_removed
is added, which is meant to be implemented by classed derived fromFlowManager
.In this PR, an
async_flow_removed
method is added toConfigEntriesFlowManager
, the method cleans up reauth issues which ensures reauth issues are always cleaned up when a reauth flow is aborted, not only if the reauth flow returns abort.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: