Return when flow changes during pre_actions #111
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.
This PR suggests a change in pre-action allowing to call
flow_manager.set_node()
inside pre-action and perform an early return on the other firstset_node
call.Consider this scenario where a pre-action changes the flow to a different node:
Then in a node configuration:
With the fix, when
check_and_redirect_user
callsset_node("onboarding", ...)
, the originalset_node("welcome", ...)
call detects the node change and returns early, preventing it from overwriting the context with the welcome node's configuration.This ensures that when a pre-action explicitly changes nodes, we respect that decision and don't continue with the original node setup.
I particularly use it to run deterministic functions before, but sometimes I don't want to keep running the original
set_node
.