[WIP] Fix error when trying to view a workflow instance
Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.
Original prompt
This section details on the original issue you should resolve
<issue_title>Error when trying to view a workflow instance</issue_title> <issue_description>## Description I have been getting this issue across multiple versions of Elsa and for certain workflow definitions, although pretty inconsistent as to why as they don't use the same activities.
I get an error when trying to view the instance, in production the error is
NullReferenceException: Arg_NullReferenceExceptionwhen running locally it is NullReferenceException: Object reference not set to an instance of an object.
- Reproduction Rate: every time
Expected Behavior
View the instance
Actual Behavior
Error is thrown
Screenshots
Environment
- Elsa Package Version: 3.4.0
Log Output
Sending HTTP request POST https://localhost:44397/elsa/api/workflow-instances/83def16940ce37f8/journal?*info: System.Net.Http.HttpClient.IWorkflowInstancesApi.ClientHandler[101] Received HTTP response headers after 50.6ms - 200 info: System.Net.Http.HttpClient.IWorkflowInstancesApi.LogicalHandler[101] End processing HTTP request after 63.1ms - 200 fail: Microsoft.AspNetCore.Components.Web.ErrorBoundary[0] System.NullReferenceException: Object reference not set to an instance of an object. at Elsa.Studio.Workflows.Components.WorkflowInstanceViewer.Components.WorkflowInstanceDetails.GetLastWorkflowActivityExecutionRecordAsync(String workflowInstanceId) at Elsa.Studio.Workflows.Components.WorkflowInstanceViewer.Components.WorkflowInstanceDetails.GetWorkflowActivityExecutionRecordAsync(String workflowInstanceId) at Elsa.Studio.Workflows.Components.WorkflowInstanceViewer.Components.WorkflowInstanceDetails.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) System.NullReferenceException: Object reference not set to an instance of an object. at Elsa.Studio.Workflows.Components.WorkflowInstanceViewer.Components.WorkflowInstanceDetails.GetLastWorkflowActivityExecutionRecordAsync(String workflowInstanceId) at Elsa.Studio.Workflows.Components.WorkflowInstanceViewer.Components.WorkflowInstanceDetails.GetWorkflowActivityExecutionRecordAsync(String workflowInstanceId) at Elsa.Studio.Workflows.Components.WorkflowInstanceViewer.Components.WorkflowInstanceDetails.OnParametersSetAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)</issue_description>
Comments on the Issue (you are @copilot in this section)
@sfmskywalker This should be much better with 3.5.0 (currently in RC)
- Fixes elsa-workflows/elsa-core#6731
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.