microsoft/semantic-kernel · error · ArgumentException

A complete then action is required for orchestration steps.

Error message

A complete then action is required for orchestration steps.

What it means

Thrown by WorkflowBuilder while iterating `thenActions` for an orchestration step: an individual action is null or its `Node` property is null/whitespace. Each `then` entry must name a concrete destination node (or the `"End"` sentinel). It is an ArgumentException raised in `AddOrchestrationStepAsync` after the edge source has already been validated.

Source

Thrown at dotnet/src/Experimental/Process.Core/Workflow/WorkflowBuilder.cs:291

                    // The source is an input event.
                    edgeBuilder = processBuilder.OnInputEvent(listenCondition.Event);
                }
                else
                {
                    throw new ArgumentException($"An orchestration is referencing a node with Id `{listenCondition.From}` that does not exist.");
                }
            }
            else
            {
                throw new ArgumentException("A complete listen_for condition is required for orchestration steps.");
            }

            // Now that we have a validated edge source, we can add the then actions
            foreach (var action in thenActions)
            {
                if (action is null || string.IsNullOrWhiteSpace(action.Node))
                {
                    throw new ArgumentException("A complete then action is required for orchestration steps.");
                }

                if (!this._stepBuilders.TryGetValue(action.Node, out ProcessStepBuilder? destinationStepBuilder))
                {
                    if (action.Node.Equals("End", StringComparison.OrdinalIgnoreCase))
                    {
                        edgeBuilder.StopProcess();
                        continue;
                    }

                    throw new ArgumentException($"An orchestration is referencing a node with Id `{action.Node}` that does not exist.");
                }

                // Add the edge to the node
                edgeBuilder = edgeBuilder.SendEventTo(new ProcessFunctionTargetBuilder(destinationStepBuilder));
            }
        }

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect every `then` entry in the orchestration step and confirm it has a non-empty `node` value.
  2. Strip null entries from the `then` collection before building.
  3. Validate the workflow structure programmatically before calling the builder.

Example fix

// before
then:
  - node: ""
// after
then:
  - node: NextStep
Defensive patterns

Strategy: validation

Validate before calling

foreach (var step in workflow.Orchestration)
{
    if (step.Then is null) continue;
    foreach (var action in step.Then)
    {
        if (action is null || string.IsNullOrWhiteSpace(action.Node))
            throw new InvalidOperationException("Each then action must have a non-empty node.");
    }
}

Type guard

bool IsValidThenAction(ThenAction a) => a is not null && !string.IsNullOrWhiteSpace(a.Node);

Try / catch

try { await builder.BuildAsync(); }
catch (ArgumentException ex) when (ex.Message.Contains("complete then action"))
{ _logger.LogError(ex, "A then action is missing its node."); throw; }

Prevention

When it happens

Trigger: Provide a `then` array containing a null entry; provide a `then` entry whose `node` key is missing or empty; deserialize a workflow where a `then` action lost its `node` field.

Common situations: Hand-editing YAML and leaving a `then:` bullet with no `node`; serialization bug producing partial `ThenAction` objects; truncation during manual editing of large orchestration lists.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/7c435925069135e0. Report an issue: GitHub.