Skip to content

Commit

Permalink
Merge pull request #402 from serverlessworkflow/fix-export-as
Browse files Browse the repository at this point in the history
Fixed the TaskExecutor to evaluate `export.as` against the task transformed output instead of context data
  • Loading branch information
cdavernas authored Sep 11, 2024
2 parents 3dd559e + c4e3600 commit 090fdb0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runner/Synapse.Runner/Services/TaskExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,15 @@ public virtual async Task SetResultAsync(object? result, string? then = FlowDire
else if (this.Task.Definition.Output?.As != null) output = await this.Task.Workflow.Expressions.EvaluateAsync<object>(this.Task.Definition.Output.As, output ?? new(), arguments, cancellationToken).ConfigureAwait(false);
if (this.Task.Definition.Export?.As is string toExpression)
{
var context = (await this.Task.Workflow.Expressions.EvaluateAsync<IDictionary<string, object>>(toExpression, this.Task.ContextData, arguments, cancellationToken).ConfigureAwait(false))!;
var context = (await this.Task.Workflow.Expressions.EvaluateAsync<IDictionary<string, object>>(toExpression, output ?? new(), arguments, cancellationToken).ConfigureAwait(false))!;
await this.Task.SetContextDataAsync(context, cancellationToken).ConfigureAwait(false);
}
else if (this.Task.Definition.Export?.As != null)
{
var context = (await this.Task.Workflow.Expressions.EvaluateAsync<IDictionary<string, object>>(this.Task.Definition.Export.As, this.Task.ContextData, arguments, cancellationToken).ConfigureAwait(false))!;
var context = (await this.Task.Workflow.Expressions.EvaluateAsync<IDictionary<string, object>>(this.Task.Definition.Export.As, output ?? new(), arguments, cancellationToken).ConfigureAwait(false))!;
await this.Task.SetContextDataAsync(context, cancellationToken).ConfigureAwait(false);
}
await this.AfterExecuteAsync(cancellationToken).ConfigureAwait(false); //todo: act upon last directive
await this.AfterExecuteAsync(cancellationToken).ConfigureAwait(false);
await this.DoSetResultAsync(output, then, cancellationToken).ConfigureAwait(false);
await this.Task.SetResultAsync(output, then, cancellationToken).ConfigureAwait(false);
this.Subject.OnNext(new TaskLifeCycleEvent(TaskLifeCycleEventType.Completed));
Expand Down

0 comments on commit 090fdb0

Please sign in to comment.