Skip to content

Commit

Permalink
Merge pull request #463 from serverlessworkflow/fix-for-single
Browse files Browse the repository at this point in the history
Fixed the `ForTaskExecutor`, which was not properly running when the list to enumerate contained only 1 item
  • Loading branch information
cdavernas authored Dec 6, 2024
2 parents 3675880 + ce39be4 commit 896b8d9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/runner/Synapse.Runner/Services/Executors/ForTaskExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ protected override async Task DoExecuteAsync(CancellationToken cancellationToken
{
if (this.Collection == null) throw new InvalidOperationException("The executor must be initialized before execution");
var task = await this.Task.GetSubTasksAsync(cancellationToken).OrderBy(t => t.CreatedAt).LastOrDefaultAsync(cancellationToken).ConfigureAwait(false);
var index = task == null ? 0 : int.Parse(task.Reference.OriginalString.Split('/', StringSplitOptions.RemoveEmptyEntries).Last());
if (index == this.Collection.Count - 1)
var index = 0;
if (task != null)
{
await this.SetResultAsync(this.Task.Input, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);
return;
index = int.Parse(task.Reference.OriginalString.Split('/', StringSplitOptions.RemoveEmptyEntries).Last());
if (index == this.Collection.Count - 1)
{
await this.SetResultAsync(this.Task.Input, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);
return;
}
}
var item = this.Collection.ElementAt(index);
var taskDefinition = new DoTaskDefinition()
Expand Down

0 comments on commit 896b8d9

Please sign in to comment.