Skip to content

Commit

Permalink
fix(Runner): Fixed the ForTaskExecutor, which was not properly runn…
Browse files Browse the repository at this point in the history
…ing when the list to enumerate contained only 1 item

Signed-off-by: Charles d'Avernas <[email protected]>
  • Loading branch information
cdavernas committed Dec 6, 2024
1 parent 3675880 commit ce39be4
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 ce39be4

Please sign in to comment.