microsoft/semantic-kernel · error · KernelException

Unable to read state from map with name '{this.State.Name}'

Error message

Unable to read state from map with name '{this.State.Name}' and Id '{this.State.Id}'.

What it means

Thrown when reconstructing a KernelProcessMap from a DaprMapInfo whose State is not a KernelProcessMapState. The Dapr runtime expects the persisted state for a map to be specifically a KernelProcessMapState; any other state type indicates a serialization or schema mismatch.

Source

Thrown at dotnet/src/Experimental/Process.Runtime.Dapr/DaprMapInfo.cs:30

[KnownType(typeof(KernelProcessStepState<>))]
public sealed record DaprMapInfo : DaprStepInfo
{
    /// <summary>
    /// The map operation
    /// </summary>
    public required DaprStepInfo Operation { get; init; }

    /// <summary>
    /// Initializes a new instance of the <see cref="KernelProcessMap"/> class from this instance of <see cref="DaprMapInfo"/>.
    /// </summary>
    /// <returns>An instance of <see cref="KernelProcessMap"/></returns>
    /// <exception cref="KernelException"></exception>
    public KernelProcessMap ToKernelProcessMap()
    {
        KernelProcessStepInfo processStepInfo = this.ToKernelProcessStepInfo();
        if (this.State is not KernelProcessMapState state)
        {
            throw new KernelException($"Unable to read state from map with name '{this.State.Name}' and Id '{this.State.Id}'.");
        }

        KernelProcessStepInfo operationStep =
            this.Operation is DaprProcessInfo processInfo
                ? processInfo.ToKernelProcess()
                : this.Operation.ToKernelProcessStepInfo();

        return new KernelProcessMap(state, operationStep, this.Edges);
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="DaprMapInfo"/> class from an instance of <see cref="KernelProcessMap"/>.
    /// </summary>
    /// <param name="processMap">The <see cref="KernelProcessMap"/> used to build the <see cref="DaprMapInfo"/></param>
    /// <returns>An instance of <see cref="DaprProcessInfo"/></returns>
    public static DaprMapInfo FromKernelProcessMap(KernelProcessMap processMap)
    {
        Verify.NotNull(processMap);

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Confirm the Semantic Kernel version persisting the process matches the version reading it back.
  2. Check the JSON serialization settings and polymorphic type discriminators for KernelProcessMapState so the correct concrete type is materialized.
  3. Inspect the persisted State JSON to verify it carries the expected $type / discriminator for KernelProcessMapState.
  4. Re-persist the process with the current runtime version after migrating any state shape changes.
Defensive patterns

Strategy: validation

Validate before calling

// Validate map state type before converting
if (daprMapInfo.State is not KernelProcessMapState)
{
    throw new InvalidOperationException($"Expected KernelProcessMapState but got {daprMapInfo.State.GetType()}.");
}

Type guard

public static bool IsValidMapState(DaprMapInfo info) =>
    info.State is KernelProcessMapState;

Try / catch

try
{
    var map = daprMapInfo.ToKernelProcessMap();
}
catch (KernelException ex) when (ex.Message.Contains("Unable to read state from map"))
{
    _logger.LogError(ex, "Map state schema mismatch; check version compatibility.");
    throw;
}

Prevention

When it happens

Trigger: DaprMapInfo.ToKernelProcessMap() checks `this.State is KernelProcessMapState` and fails. Triggered when loading a map whose state was persisted under a different schema or got deserialized into the wrong concrete state type.

Common situations: Version upgrades that renamed or restructured KernelProcessMapState, JSON polymorphism configuration changes, or a map definition that was persisted by a newer/older runtime version than the one reading it.

Related errors


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