From ede5d5cad2e59c49ebf992c210e13deb3ed4d83a Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 28 Mar 2025 20:56:47 +0100 Subject: [PATCH] Fix null handling for cancellation tokens and string fields Updated `_linkedTokenSource` initialization to allow null values and improved string field handling by applying `NullIfEmpty()` for `CorrelationId`, `TriggerActivityId`, and `ParentWorkflowInstanceId`. These changes ensure proper null-state management and eliminate potential discrepancies in downstream operations. --- .../Actors/WorkflowInstance.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/Elsa.Workflows.Runtime.ProtoActor/Actors/WorkflowInstance.cs b/src/modules/Elsa.Workflows.Runtime.ProtoActor/Actors/WorkflowInstance.cs index 748197690..2039857a7 100644 --- a/src/modules/Elsa.Workflows.Runtime.ProtoActor/Actors/WorkflowInstance.cs +++ b/src/modules/Elsa.Workflows.Runtime.ProtoActor/Actors/WorkflowInstance.cs @@ -21,7 +21,7 @@ internal class WorkflowInstance( private string? _workflowInstanceId; private WorkflowGraph? _workflowGraph; private WorkflowState? _workflowState; - private CancellationTokenSource _linkedTokenSource = default!; + private CancellationTokenSource _linkedTokenSource = null!; private CancellationToken _linkedCancellationToken; private readonly Queue _queuedRunWorkflowOptions = new(); private bool _isRunning; @@ -137,8 +137,8 @@ internal class WorkflowInstance( ActivityHandle = mappers.ActivityHandleMapper.Map(request.ActivityHandle), Properties = request.Properties.DeserializeProperties(), Input = request.Input.DeserializeInput(), - CorrelationId = request.CorrelationId, - TriggerActivityId = request.TriggerActivityId + CorrelationId = request.CorrelationId.NullIfEmpty(), + TriggerActivityId = request.TriggerActivityId.NullIfEmpty() }; var result = await RunAsync(runWorkflowOptions); @@ -266,7 +266,7 @@ internal class WorkflowInstance( CorrelationId = request.CorrelationId.NullIfEmpty(), Input = request.Input.DeserializeInput(), Properties = request.Properties.DeserializeProperties(), - ParentWorkflowInstanceId = request.ParentId + ParentWorkflowInstanceId = request.ParentId.NullIfEmpty() }; await using var scope = scopeFactory.CreateAsyncScope();