Skip to content

Commit 896b8d9

Browse files
authored
Merge pull request #463 from serverlessworkflow/fix-for-single
Fixed the `ForTaskExecutor`, which was not properly running when the list to enumerate contained only 1 item
2 parents 3675880 + ce39be4 commit 896b8d9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: src/runner/Synapse.Runner/Services/Executors/ForTaskExecutor.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ protected override async Task DoExecuteAsync(CancellationToken cancellationToken
6868
{
6969
if (this.Collection == null) throw new InvalidOperationException("The executor must be initialized before execution");
7070
var task = await this.Task.GetSubTasksAsync(cancellationToken).OrderBy(t => t.CreatedAt).LastOrDefaultAsync(cancellationToken).ConfigureAwait(false);
71-
var index = task == null ? 0 : int.Parse(task.Reference.OriginalString.Split('/', StringSplitOptions.RemoveEmptyEntries).Last());
72-
if (index == this.Collection.Count - 1)
71+
var index = 0;
72+
if (task != null)
7373
{
74-
await this.SetResultAsync(this.Task.Input, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);
75-
return;
74+
index = int.Parse(task.Reference.OriginalString.Split('/', StringSplitOptions.RemoveEmptyEntries).Last());
75+
if (index == this.Collection.Count - 1)
76+
{
77+
await this.SetResultAsync(this.Task.Input, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);
78+
return;
79+
}
7680
}
7781
var item = this.Collection.ElementAt(index);
7882
var taskDefinition = new DoTaskDefinition()

0 commit comments

Comments
 (0)