Skip to content

fix: add logic to end the trigger when is_end_node field of workflow_… - #1818

Open
samark231 wants to merge 1 commit into
mainfrom
fix/workflow-end-when-is-end-node-true
Open

fix: add logic to end the trigger when is_end_node field of workflow_…#1818
samark231 wants to merge 1 commit into
mainfrom
fix/workflow-end-when-is-end-node-true

Conversation

@samark231

Copy link
Copy Markdown
Collaborator

Summary of Changes

Honor workflow_node_mapping.is_end_node in the workflow engine. The column was being persisted by the builder and round-tripped to the frontend, but the runtime engine never read it — so a node marked as the end in the UI would still execute downstream nodes if its config_json.routing had a goto.

Now, after a node's handler runs, the engine checks current.getIsEndNode() and continues if true — terminating just that branch without evaluating routing or pushing successors. The handler still executes for the end node so any final side-effect (closing email, status update, etc.) is honored.

Path-only semantics: other branches already on the execution stack (multi-goto fan-out / diamond DAGs) keep running. To end an entire workflow, every terminal leaf must be marked is_end_node = true. Rationale is documented inline so this isn't misread as a kill-switch later.

Backend:

  • Add is_end_node check in WorkflowEngineService.run() between the handler invocation and evaluateRoutingNextNodeIds() — uses Boolean.TRUE.equals(...) so legacy null rows behave as false and need no migration
  • Add block comment documenting the path-only termination semantics and why we use continue (preserves diamond-DAG support) over clearing the stack
  • Existing termination signals preserved unchanged: empty routing array, {"type": "end"} route, and literal targetNodeId == "end" string

Frontend:

  • None

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

How Has This Been Tested?

  • Linear workflow with the last node marked is_end_node=true: handler runs, path ends, no further nodes processed
  • Linear workflow with is_end_node=true mid-chain and a downstream goto: confirmed downstream node is NOT executed (previously was)
  • Node with is_end_node=false/null and routing present: existing behavior unchanged — successors still pushed
  • Diamond DAG sanity check: a path terminating via is_end_node does not affect other branches already on the execution stack

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have updated the documentation accordingly

@codacy-production

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant