microsoft/semantic-kernel · error · KernelException

Type '{stepStateType.Value}' could not be resolved to a vali

Error message

Type '{stepStateType.Value}' could not be resolved to a valid KernelProcessStepState type.

What it means

During ActivateStepAsync, if persisted state exists (ActorStateKeys.StepStateType), the actor loads the state type name and calls Type.GetType to resolve it. If Type.GetType returns null — the type name cannot be resolved to a CLR type — this KernelException is thrown. This is the persisted-state analogue of error 548, but for state types rather than step types.

Source

Thrown at dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs:383

            this._functions.Add(f.Name, f);
        }

        // Initialize the input channels
        this._initialInputs = this.GenerateInitialInputs();
        this._inputs = this._initialInputs.ToDictionary(kvp => kvp.Key, kvp => kvp.Value?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));

        // Activate the step with user-defined state if needed
        KernelProcessStepState? stateObject = null;
        Type? stateType = null;

        // Check if the state has already been persisted
        var stepStateType = await this.StateManager.TryGetStateAsync<string>(ActorStateKeys.StepStateType).ConfigureAwait(false);
        if (stepStateType.HasValue)
        {
            stateType = Type.GetType(stepStateType.Value);
            if (stateType is null)
            {
                throw new KernelException($"Type '{stepStateType.Value}' could not be resolved to a valid KernelProcessStepState type.").Log(this._logger);
            }

            if (!typeof(KernelProcessStepState).IsAssignableFrom(stateType))
            {
                throw new KernelException($"Type '{stepStateType.Value}' is not a valid KernelProcessStepState type.").Log(this._logger);
            }

            var stateObjectJson = await this.StateManager.GetStateAsync<string>(ActorStateKeys.StepStateJson).ConfigureAwait(false);
            stateObject = JsonSerializer.Deserialize(stateObjectJson, stateType) as KernelProcessStepState;
        }
        else
        {
            stateType = this._innerStepType.ExtractStateType(out Type? userStateType, this._logger);
            stateObject = this._stepInfo.State;

            // Persist the state type and type object.
            await this.StateManager.AddStateAsync(ActorStateKeys.StepStateType, stateType.AssemblyQualifiedName).ConfigureAwait(false);
            await this.StateManager.AddStateAsync(ActorStateKeys.StepStateJson, JsonSerializer.Serialize(stateObject)).ConfigureAwait(false);

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure the assembly containing the KernelProcessStepState-derived state type is loaded by the Dapr actor host process.
  2. If the state type was renamed or moved, clear the persisted state (StepStateType and StepStateJson) so the actor re-derives it from the step type, or migrate the persisted state to the new type name.
  3. Verify the persisted StepStateType value is a valid assembly-qualified name by inspecting the Dapr state store.
Defensive patterns

Strategy: validation

Validate before calling

// When re-activating from persisted state, verify the state type is resolvable:
var stepStateType = await stateManager.TryGetStateAsync<string>(ActorStateKeys.StepStateType);
if (stepStateType.HasValue)
{
    Type? t = Type.GetType(stepStateType.Value);
    if (t is null)
    {
        logger.LogWarning("Persisted state type '{Type}' cannot be resolved. Clearing persisted state.", stepStateType.Value);
        // Clear and let the actor re-derive from the step type
    }
}

Type guard

static bool IsStateTypeLoadable(string assemblyQualifiedName)
{
    return Type.GetType(assemblyQualifiedName) is not null;
}

Try / catch

try
{
    await stepActor.PrepareIncomingMessagesAsync(); // triggers lazy activation
}
catch (KernelException ex) when (ex.Message.Contains("could not be resolved to a valid KernelProcessStepState type"))
{
    logger.LogError("Persisted state type not loadable. Clear Dapr state or ensure the assembly is referenced.");
}

Prevention

When it happens

Trigger: The actor is re-activated from persisted Dapr state. StepStateType contains an assembly-qualified name that Type.GetType cannot resolve. This happens when the assembly containing the state type is not loaded, the state type was renamed, or the persisted name is malformed.

Common situations: Deploying a new version of the step assembly that changed the state type's namespace, name, or assembly. The state type lives in a different assembly that the actor host does not reference. Corrupted or truncated persisted state in the Dapr state store.

Related errors


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