Skip to content

Commit

Permalink
Merge pull request #486 from serverlessworkflow/fix-next-task-resolution
Browse files Browse the repository at this point in the history
Fix the `WorkflowDefinitionExtensions` and `DoTaskDefinitionExtensions` to rely on name to determine the next task
  • Loading branch information
cdavernas authored Jan 23, 2025
2 parents 9855378 + f8af3af commit 9a5fc4d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public static class DoTaskDefinitionExtensions
switch (after.Next)
{
case FlowDirective.Continue:
var afterTask = doTask.Do[after.Name!];
var afterIndex = doTask.Do.Select(t => t.Value).ToList().IndexOf(afterTask);
var afterIndex = doTask.Do.Select(t => t.Key).ToList().IndexOf(after.Name!);
return doTask.Do.Skip(afterIndex + 1).FirstOrDefault();
case FlowDirective.End: case FlowDirective.Exit: return default;
default: return new(after.Next!, doTask.Do[after.Next!]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public static class WorkflowDefinitionExtensions
switch (after.Status == TaskInstanceStatus.Skipped ? FlowDirective.Continue : after.Next)
{
case FlowDirective.Continue:
var afterTask = workflow.Do[after.Name!];
var afterIndex = workflow.Do.Select(e => e.Value).ToList().IndexOf(afterTask);
var afterIndex = workflow.Do.Select(kvp => kvp.Key).ToList().IndexOf(after.Name!);
return workflow.Do.Skip(afterIndex + 1).FirstOrDefault();
case FlowDirective.End: case FlowDirective.Exit: return default;
default: return new(after.Next!, workflow.Do[after.Next!]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public virtual async Task<TaskInstance> CreateTaskAsync(TaskDefinition definitio
}
else
{
var contextDocument = await this.Documents.CreateAsync($"{reference}/input", context, cancellationToken).ConfigureAwait(false);
var contextDocument = await this.Documents.CreateAsync($"{reference}/context", context, cancellationToken).ConfigureAwait(false);
contextReference = contextDocument.Id;
}
var filteredInput = input;
Expand Down

0 comments on commit 9a5fc4d

Please sign in to comment.