{"record":{"id":"411ab9e117f91e8c","repo":"microsoft/semantic-kernel","slug":"the-process-must-be-initialized-before-accessing-t","errorCode":null,"errorMessage":"The Process must be initialized before accessing the Name property.","messagePattern":"The Process must be initialized before accessing the Name property\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Runtime.Dapr/Actors/ProcessActor.cs","lineNumber":187,"sourceCode":"    protected override async Task OnActivateAsync()\n    {\n        var existingProcessInfo = await this.StateManager.TryGetStateAsync<DaprProcessInfo>(ActorStateKeys.ProcessInfoState).ConfigureAwait(false);\n        if (existingProcessInfo.HasValue)\n        {\n            this.ParentProcessId = await this.StateManager.GetStateAsync<string>(ActorStateKeys.StepParentProcessId).ConfigureAwait(false);\n            string? eventProxyStepId = null;\n            if (await this.StateManager.ContainsStateAsync(ActorStateKeys.EventProxyStepId).ConfigureAwait(false))\n            {\n                eventProxyStepId = await this.StateManager.GetStateAsync<string>(ActorStateKeys.EventProxyStepId).ConfigureAwait(false);\n            }\n            await this.InitializeProcessActorAsync(existingProcessInfo.Value, this.ParentProcessId, eventProxyStepId).ConfigureAwait(false);\n        }\n    }\n\n    /// <summary>\n    /// The name of the step.\n    /// </summary>\n    protected override string Name => this._process?.State.Name ?? throw new KernelException(\"The Process must be initialized before accessing the Name property.\").Log(this._logger);\n\n    #endregion\n\n    /// <summary>\n    /// Handles a <see cref=\"ProcessMessage\"/> that has been sent to the process. This happens only in the case\n    /// of a process (this one) running as a step within another process (this one's parent). In this case the\n    /// entire sub-process should be executed within a single superstep.\n    /// </summary>\n    /// <param name=\"message\">The message to process.</param>\n    internal override async Task HandleMessageAsync(ProcessMessage message)\n    {\n        if (string.IsNullOrWhiteSpace(message.TargetEventId))\n        {\n            throw new KernelException(\"Internal Process Error: The target event id must be specified when sending a message to a step.\").Log(this._logger);\n        }\n\n        string eventId = message.TargetEventId!;\n        if (this._outputEdges!.TryGetValue(eventId, out List<KernelProcessEdge>? edges) && edges is not null)","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Runtime.Dapr/Actors/ProcessActor.cs#L169-L205","documentation":"The ProcessActor.Name property getter throws this KernelException when the internal _process field (a DaprProcessInfo) is null. The _process field is only assigned inside InitializeProcessActorAsync, so any access to Name before that call completes will fail. Name is used internally by logging, ToDaprProcessInfoAsync, ScopedEvent, and other paths, so the throw can surface indirectly.","triggerScenarios":"Calling GetProcessInfoAsync(), ToDaprStepInfoAsync(), or any method that touches this.Name on a ProcessActor that was never initialized via InitializeProcessAsync(). Also occurs if OnActivateAsync finds no persisted ProcessInfoState in the Dapr state store (e.g. first activation with no prior save) and a subsequent method reads Name before InitializeProcessActorAsync runs.","commonSituations":"Process actor activated from scratch with no persisted state, a race where a method runs before initialization completes, or calling GetProcessInfoAsync on a freshly created process actor proxy that has not had InitializeProcessAsync invoked yet.","solutions":["Ensure InitializeProcessAsync (which delegates to InitializeProcessActorAsync and sets _process) is awaited before calling GetProcessInfoAsync, StartAsync, or any other method that reads the process name.","Verify that the Dapr actor state store contains ActorStateKeys.ProcessInfoState for re-activated actors, confirming the process was previously initialized and its state persisted.","Check that the actor proxy is targeting the correct actor ID so that persisted state, if it exists, is found by OnActivateAsync."],"exampleFix":"// before\nvar proxy = actorProxyFactory.CreateActorProxy<IProcess>(actorId, nameof(ProcessActor));\nvar info = await proxy.GetProcessInfoAsync(); // throws if not initialized\n\n// after\nvar proxy = actorProxyFactory.CreateActorProxy<IProcess>(actorId, nameof(ProcessActor));\nawait proxy.InitializeProcessAsync(processInfo, parentProcessId: null); // sets _process\nvar info = await proxy.GetProcessInfoAsync();","handlingStrategy":"validation","validationCode":"// Before accessing process info or starting, verify initialization by attempting GetProcessInfoAsync\n// in a try-catch, or track initialization externally:\nbool isInitialized = false;\ntry\n{\n    await processProxy.InitializeProcessAsync(processInfo, parentProcessId);\n    isInitialized = true;\n}\ncatch { /* handle */ }\n\nif (isInitialized)\n{\n    var info = await processProxy.GetProcessInfoAsync();\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var info = await processProxy.GetProcessInfoAsync();\n}\ncatch (KernelException ex) when (ex.Message.Contains(\"The Process must be initialized\"))\n{\n    // Process not initialized — call InitializeProcessAsync first\n    logger.LogWarning(\"Process actor not initialized. Call InitializeProcessAsync before use.\");\n}","preventionTips":["Always call and await InitializeProcessAsync before any other method on a ProcessActor proxy.","For re-activated actors, verify the Dapr state store contains ActorStateKeys.ProcessInfoState.","Wrap process-actor initialization in a helper that prevents usage before initialization completes."],"tags":["dapr","process-runtime","initialization","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}