{"record":{"id":"be8b352dbd512fd3","repo":"microsoft/semantic-kernel","slug":"the-step-must-be-initialized-before-accessing-the","errorCode":null,"errorMessage":"The Step must be initialized before accessing the Name property.","messagePattern":"The Step must be initialized before accessing the Name property\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs","lineNumber":211,"sourceCode":"                eventProxyStepId = await this.StateManager.GetStateAsync<string>(ActorStateKeys.EventProxyStepId).ConfigureAwait(false);\n            }\n            this.InitializeStep(existingStepInfo.Value, parentProcessId, eventProxyStepId);\n\n            // Load the persisted incoming messages\n            var incomingMessages = await this.StateManager.TryGetStateAsync<Queue<ProcessMessage>>(ActorStateKeys.StepIncomingMessagesState).ConfigureAwait(false);\n            if (incomingMessages.HasValue)\n            {\n                this._incomingMessages = incomingMessages.Value;\n            }\n        }\n    }\n\n    #endregion\n\n    /// <summary>\n    /// The name of the step.\n    /// </summary>\n    protected virtual string Name => this._stepInfo?.State.Name ?? throw new KernelException(\"The Step must be initialized before accessing the Name property.\").Log(this._logger);\n\n    /// <summary>\n    /// Emits an event from the step.\n    /// </summary>\n    /// <param name=\"processEvent\">The event to emit.</param>\n    /// <returns>A <see cref=\"ValueTask\"/></returns>\n    public ValueTask EmitEventAsync(KernelProcessEvent processEvent) => this.EmitEventAsync(ProcessEvent.Create(processEvent, this._eventNamespace!));\n\n    // TODO: this can be moved to shared runtime code, looks almost/same to localRuntime implementation\n    internal virtual void AssignStepFunctionParameterValues(ProcessMessage message)\n    {\n        if (this._functions is null || this._inputs is null || this._initialInputs is null)\n        {\n            throw new KernelException(\"The step has not been initialized.\").Log(this._logger);\n        }\n\n        // Add the message values to the inputs for the function\n        foreach (var kvp in message.Values)","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Runtime.Dapr/Actors/StepActor.cs#L193-L229","documentation":"StepActor.Name returns this._stepInfo?.State.Name, throwing if _stepInfo is null. The _stepInfo field is assigned in InitializeStep (called by InitializeStepAsync or OnActivateAsync). Accessing Name before initialization completes triggers this KernelException. Name is used internally by logging and error messages.","triggerScenarios":"Any code path that reads this.Name before InitializeStepAsync (or OnActivateAsync from persisted state) has set _stepInfo. This includes EmitEventAsync logging, HandleMessageAsync logging, and ToDaprStepInfoAsync.","commonSituations":"A step actor proxy is created and a method is called before InitializeStepAsync. The actor is re-activated but no persisted StepInfoState exists in the Dapr state store. A race condition where a message arrives before initialization.","solutions":["Ensure InitializeStepAsync is awaited before invoking any method on the step actor proxy.","Verify that the Dapr actor state store has ActorStateKeys.StepInfoState for re-activated step actors.","If the actor is freshly created, always call InitializeStepAsync first before SendAsync, PrepareIncomingMessagesAsync, or ProcessIncomingMessagesAsync."],"exampleFix":"// before\nvar stepProxy = factory.CreateActorProxy<IStep>(stepId, nameof(StepActor));\nawait stepProxy.PrepareIncomingMessagesAsync(); // throws if not initialized\n\n// after\nvar stepProxy = factory.CreateActorProxy<IStep>(stepId, nameof(StepActor));\nawait stepProxy.InitializeStepAsync(stepInfo, parentProcessId);\nawait stepProxy.PrepareIncomingMessagesAsync();","handlingStrategy":"validation","validationCode":"// Ensure InitializeStepAsync is called before any other operation:\nawait stepActor.InitializeStepAsync(stepInfo, parentProcessId);\n// Only then proceed with message processing or state extraction:\nawait stepActor.PrepareIncomingMessagesAsync();","typeGuard":null,"tryCatchPattern":"try\n{\n    var info = await stepActor.ToDaprStepInfoAsync();\n}\ncatch (KernelException ex) when (ex.Message.Contains(\"Step must be initialized\"))\n{\n    logger.LogError(\"Step actor not initialized. Call InitializeStepAsync first.\");\n}","preventionTips":["Call and await InitializeStepAsync before any other method on a step actor proxy.","Verify the Dapr state store has StepInfoState for re-activated actors.","Track initialization state externally when orchestrating multiple step actors."],"tags":["dapr","process-runtime","initialization","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}