From 7739a65189671b2561e05bb2706b1ab669c63c46 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Mon, 26 Apr 2021 12:30:44 +0200 Subject: [PATCH] Prevent RunWorkflow from executing the workflow it is itself part of --- .../Activities/Workflows/RunWorkflow/RunWorkflow.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs b/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs index 8144ea28d..7c3922b7e 100644 --- a/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs +++ b/src/core/Elsa.Core/Activities/Workflows/RunWorkflow/RunWorkflow.cs @@ -16,7 +16,7 @@ namespace Elsa.Activities.Workflows [Activity( Category = "Workflows", Description = "Runs a child workflow.", - Outcomes = new[] { OutcomeNames.Done } + Outcomes = new[] { OutcomeNames.Done, "Not Found" } )] public class RunWorkflow : Activity { @@ -84,6 +84,10 @@ namespace Elsa.Activities.Workflows { var cancellationToken = context.CancellationToken; var workflowBlueprint = await FindWorkflowBlueprintAsync(cancellationToken); + + if (workflowBlueprint == null || workflowBlueprint.Id == context.WorkflowInstance.DefinitionId) + return Outcome("Not Found"); + var workflowInstance = await _startsWorkflow.StartWorkflowAsync(workflowBlueprint!, TenantId, Input, CorrelationId, ContextId, cancellationToken); var workflowStatus = workflowInstance.WorkflowStatus;