elsa-workflows / elsa-workflows/elsa-core
ELSA 3.5.1 WorkflowInstanceStorageDriver. Exceptions while deserializing List<ExpandoObject> variables
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
After updating to ELSA 3.5.1, the default variable storage is `Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core`. I think there is a problem in serializing/deserializing `List` variables & ios.
Only as example, I have a custom script to select entities (functionalty does not matter) which is called within a JavaScript activity and return a `List`. The result is stored within a variable.
```
engine.SetValue($"findIngredientsFor{alias}", (Func>)((select) =>
{
var results = new List();
...
return results;
}));
```
The result is stored in a variable and looks like this...
```
[
{ "Guid": ..., "Partial": true...},
{ "Guid": ..., "Partial": true...}
]
```
In mongoDb it is stored as...
When the workflow instance is deserialized (for example on resumes or within deletion), I get a serialization error:
```
2025-10-16 15:46:05.993 [AZO.KastorEngine.Server][1.0.0.0] [Error] [WorkflowElsaSystem] Workflow: <>:0000002484 not triggered. Error: An error occurred while deserializing the WorkflowState property of class Elsa.Workflows.Management.Entities.WorkflowInstance: An error occurred while deserializing the ActivityExecutionContexts property of class Elsa.Workflows.State.WorkflowState: An error occurred while deserializing the ActivityState property of class Elsa.Workflows.State.ActivityExecutionContextState: Cannot dynamically create an instance of type 'System.Text.Json.Nodes.JsonObject'. Reason: No parameterless constructor defined.
AZO.KastorEngine.Systems.Workflow.Exceptions.EcsWorkflowException: Workflow: <>:0000002484 not triggered. Error: An error occurred while deserializing the WorkflowState property of class Elsa.Workflows.Management.Entities.WorkflowInstance: An error occurred while deserializing the ActivityExecutionContexts property of class Elsa.Workflows.State.WorkflowState: An error occurred while deserializing the ActivityState property of class Elsa.Workflows.State.ActivityExecutionContextState: Cannot dynamically create an instance of type 'System.Text.Json.Nodes.JsonObject'. Reason: No parameterless constructor defined.
```
Can you please take a look at this problem?
All my existings workflows are based on `Elsa.Workflows.Services.WorkflowStorageDriver, Elsa.Workflows.Core` which is marked as deprecated in 3.5.1. Not problems at all here. At the moment, I set all new variables manually to `Elsa.Workflows.Services.WorkflowStorageDriver`. Works, but is not fine and causes very bad errors, if it will be forgotten.
I tried to force the exception with a minimal example, but I am not able to reproduce it in that way...
Thank you!
Regards Jochen Steinbrenner
## Environment
- ELSA 3.5.1 as backend
- ELSA 3.5.1 as studio docker container
- MongoDb persistaion
Contributor guide
Research direction
Start at Elsa.Workflows.Management.Entities.WorkflowInstance.WorkflowState deserialization and follow the ActivityExecutionContexts and ActivityState path to the JsonObject construction error. Compare the default WorkflowInstanceStorageDriver with the deprecated WorkflowStorageDriver using MongoDB persistence. Done means the reported List workflow state deserializes successfully without requiring manual storage-driver selection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, mongodb
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100