fix(ui): error loading workflows #7870
Merged
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.
Summary
Fixes an error when loading workflows. Looks like this:

It occurs when a workflow has invalid edges. For example, between nodes that don't exist on the Invoke installation.
Technical explanation
Previously, reactflow appears to have handled an edge case when using its
applyChanges
utility. If a change was provided without an item, it would skip that change. For example, an "add edge" change that somehow passednull
as the edge, instead of a valid edge.In our workflow loading and validation logic, invalid edges were removed from the array using
delete edges[i]
. This left "holes" in the array of edges. We then askedreactflow
to add these edges to state. When it encountered one of the "holes", it skipped over it.In a recent release (unsure which, somewhere between the latest v11 and ~v12.4) this seems to have changed. It no longer skips over the "holes" and instead trusts the data. This can cause a couple issues:
reactflow
attempt to do anything with the nonexistent edge.Two-part fix:
delete edges[i]
. Instead, as we check each edge, we add invalid ones to a set. Then, after all the checks are finished, filter out the invalid edges. The resultant edges array has no holes.reactflow
'sapplyChanges
utils, but this does literally nothing except take extra CPU cycles. We can simply set the loaded nodes and edges directly in redux. Perhaps we were usingapplyChanges
because it addressed the "holes" issue? Not sure. But we don't need it now.Related Issues / Discussions
Closes #7868
QA Instructions
Try loading some workflows that reference nodes which are not installed.
Merge Plan
n/a
Checklist
What's New
copy (if doing a release after this PR)