{"record":{"id":"bebee18c3a101a60","repo":"microsoft/semantic-kernel","slug":"type-stepstatetype-value-could-not-be-resolved","errorCode":null,"errorMessage":"Type '{stepStateType.Value}' could not be resolved to a valid KernelProcessStepState type.","messagePattern":"Type '(.+?)' could not be resolved to a valid KernelProcessStepState type\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs","lineNumber":383,"sourceCode":"            this._functions.Add(f.Name, f);\n        }\n\n        // Initialize the input channels\n        this._initialInputs = this.GenerateInitialInputs();\n        this._inputs = this._initialInputs.ToDictionary(kvp => kvp.Key, kvp => kvp.Value?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));\n\n        // Activate the step with user-defined state if needed\n        KernelProcessStepState? stateObject = null;\n        Type? stateType = null;\n\n        // Check if the state has already been persisted\n        var stepStateType = await this.StateManager.TryGetStateAsync<string>(ActorStateKeys.StepStateType).ConfigureAwait(false);\n        if (stepStateType.HasValue)\n        {\n            stateType = Type.GetType(stepStateType.Value);\n            if (stateType is null)\n            {\n                throw new KernelException($\"Type '{stepStateType.Value}' could not be resolved to a valid KernelProcessStepState type.\").Log(this._logger);\n            }\n\n            if (!typeof(KernelProcessStepState).IsAssignableFrom(stateType))\n            {\n                throw new KernelException($\"Type '{stepStateType.Value}' is not a valid KernelProcessStepState type.\").Log(this._logger);\n            }\n\n            var stateObjectJson = await this.StateManager.GetStateAsync<string>(ActorStateKeys.StepStateJson).ConfigureAwait(false);\n            stateObject = JsonSerializer.Deserialize(stateObjectJson, stateType) as KernelProcessStepState;\n        }\n        else\n        {\n            stateType = this._innerStepType.ExtractStateType(out Type? userStateType, this._logger);\n            stateObject = this._stepInfo.State;\n\n            // Persist the state type and type object.\n            await this.StateManager.AddStateAsync(ActorStateKeys.StepStateType, stateType.AssemblyQualifiedName).ConfigureAwait(false);\n            await this.StateManager.AddStateAsync(ActorStateKeys.StepStateJson, JsonSerializer.Serialize(stateObject)).ConfigureAwait(false);","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs#L365-L401","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the assembly containing the KernelProcessStepState-derived state type is loaded by the Dapr actor host process.","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.","Verify the persisted StepStateType value is a valid assembly-qualified name by inspecting the Dapr state store."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// When re-activating from persisted state, verify the state type is resolvable:\nvar stepStateType = await stateManager.TryGetStateAsync<string>(ActorStateKeys.StepStateType);\nif (stepStateType.HasValue)\n{\n    Type? t = Type.GetType(stepStateType.Value);\n    if (t is null)\n    {\n        logger.LogWarning(\"Persisted state type '{Type}' cannot be resolved. Clearing persisted state.\", stepStateType.Value);\n        // Clear and let the actor re-derive from the step type\n    }\n}","typeGuard":"static bool IsStateTypeLoadable(string assemblyQualifiedName)\n{\n    return Type.GetType(assemblyQualifiedName) is not null;\n}","tryCatchPattern":"try\n{\n    await stepActor.PrepareIncomingMessagesAsync(); // triggers lazy activation\n}\ncatch (KernelException ex) when (ex.Message.Contains(\"could not be resolved to a valid KernelProcessStepState type\"))\n{\n    logger.LogError(\"Persisted state type not loadable. Clear Dapr state or ensure the assembly is referenced.\");\n}","preventionTips":["Ensure the assembly containing state types is loaded by the actor host.","Clear persisted Dapr state when migrating to a new version that changes state types.","Maintain backward compatibility for state type names across deployments."],"tags":["dapr","process-runtime","type-resolution","persisted-state","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}