microsoft/semantic-kernel · error · KernelException

Map operation is not a process.

Error message

Map operation is not a process.

What it means

Thrown by ProcessMapBuilder.WhereInputEventIs when the MapOperation is not a ProcessBuilder (i.e. the map operation is a plain step, not a sub-process). WhereInputEventIs on a map only makes sense when the map operation is a full process that exposes external input events; a single step has no external event surface.

Source

Thrown at dotnet/src/Experimental/Process.Core/ProcessMapBuilder.cs:43

    /// <summary>
    /// Version of the map-step, used when saving the state of the step.
    /// </summary>
    public string Version { get; init; } = "v1";

    /// <summary>
    /// Retrieves the target for a given external event. The step associated with the target is the process itself (this).
    /// </summary>
    /// <param name="eventId">The Id of the event</param>
    /// <returns>An instance of <see cref="ProcessFunctionTargetBuilder"/></returns>
    /// <exception cref="KernelException"></exception>
    public ProcessFunctionTargetBuilder WhereInputEventIs(string eventId)
    {
        Verify.NotNullOrWhiteSpace(eventId, nameof(eventId));

        if (this.MapOperation is not ProcessBuilder process)
        {
            throw new KernelException("Map operation is not a process.");
        }

        ProcessFunctionTargetBuilder operationTarget = process.WhereInputEventIs(eventId);

        return operationTarget with { Step = this, TargetEventId = eventId };
    }

    /// <summary>
    /// The map operation that will be executed for each element in the input.
    /// </summary>
    internal ProcessStepBuilder MapOperation { get; }

    /// <inheritdoc/>
    /// <remarks>
    /// Never called as the map is a proxy for the map operation and does not have a function target.
    /// </remarks>
    internal override Dictionary<string, KernelFunctionMetadata> GetFunctionMetadataMap()
    {

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. If the map operation is a single step, do not call WhereInputEventIs on the map — target the step's function directly.
  2. If you need external event routing into the map, make the map operation a ProcessBuilder sub-process instead of a single step.

Example fix

// before
var map = process.AddMap(mySingleStep); // map operation is a step
map.WhereInputEventIs("StartEvent"); // throws

// after — target the step's function directly, or use a sub-process
var subProcess = new ProcessBuilder("SubProcess");
subProcess.AddStepFromType<MyStep>();
var map = process.AddMap(subProcess);
map.WhereInputEventIs("StartEvent"); // OK — map operation is a process
Defensive patterns

Strategy: type-guard

Validate before calling

if (map.MapOperation is not ProcessBuilder)
    throw new InvalidOperationException(
        "WhereInputEventIs requires the map operation to be a ProcessBuilder. For a single-step map, target the step directly.");

map.WhereInputEventIs(eventId);

Type guard

bool IsMapProcess(ProcessMapBuilder map) => map.MapOperation is ProcessBuilder;

Prevention

When it happens

Trigger: Calling mapBuilder.WhereInputEventIs(eventId) when the ProcessMapBuilder was created with a ProcessStepBuilder (a single step) rather than a ProcessBuilder (a sub-process) as its map operation.

Common situations: Creating a map with AddMap(myStep) where myStep is a single step, then trying to route external events into the map as if it were a sub-process; misunderstanding the difference between a map-of-step and a map-of-process.

Related errors


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