Add validation before getting workflow in GenerateWorkflowInputAccessors

This commit introduces a validation check in the GenerateWorkflowInputAccessors handler before trying to get the workflow. This prevents any potential issues if the workflow execution context is not available or retrievable. The code flow now first attempts to get the workflow execution context and if it's not available, it will return a completed task.
This commit is contained in:
Sipke Schoorstra 2024-05-28 23:00:47 +02:00
parent 41110774a1
commit 4393d95505

View file

@ -18,7 +18,11 @@ public class GenerateWorkflowInputAccessors : INotificationHandler<EvaluatingCSh
{
var expressionExecutionContext = notification.Context;
var workflowInputs = expressionExecutionContext.GetWorkflowInputs().ToList();
var workflow = expressionExecutionContext.GetWorkflowExecutionContext().Workflow;
if (!expressionExecutionContext.TryGetWorkflowExecutionContext(out var workflowExecutionContext))
return Task.CompletedTask;
var workflow = workflowExecutionContext.Workflow;
var inputDefinitions = workflow.Inputs.ToList();
var sb = new StringBuilder();
sb.AppendLine("public partial class WorkflowInputsProxy {");