elsa-workflows / elsa-workflows/elsa-core

Elsa 3.3.3. Breaking changes or error within MongoDb Object serialization

Open
#6,408 0 comments 1 reaction 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

## Description
Within Version 3.2.0 it was possible to create variables simply as type object. No matter if the variable contains an array of objects or a single object.
It was possible to store an array of objects within a variable "items" with type object. The "items" can be simply iterated using the "ForEach" activity with the iterator variable "item" with type object. For example:

![Image](https://github.com/user-attachments/assets/37244438-4283-4269-878a-e1e338c5d4e9)

with ForEach:

![Image](https://github.com/user-attachments/assets/660b37c2-8b90-47c7-91ca-234723643753)

My custom delay activity simple "suspends" the workflow and resumes it after the defined time in order to force
a persistation and deserialization of the workflow instance from the MongoDb.

Within version 3.2.0 the test workflow above works without any errors:
I1/N1
I2/N2
I3/N3

Within version 3.3.3 i'am getting serialization error while resuming the workflow:

```
I1/N1
I2/N2
2025-02-13 16:49:18.310 [AZO.KastorEngine.Server][1.0.0.0] [Error] [WorkflowElsaSystem] Workflow: <>:TEST_ARRAY2/2025-02-13 16:49:12Z 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: Type 'System.Text.Json.Nodes.JsonArray' does not have a suitable constructor or Add method.
AZO.KastorEngine.Systems.Workflow.Exceptions.EcsWorkflowException: Workflow: <>:TEST_ARRAY2/2025-02-13 16:49:12Z 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: Type 'System.Text.Json.Nodes.JsonArray' does not have a suitable constructor or Add method.
at AZO.KastorEngine.Systems.WorkflowElsa.WorkflowElsaSystem.TryResumeWorkflowInstance(EcsEntity entity, String bookmarkId, WorkflowState& workflowState, Dictionary`2 inputParameters, Boolean mustFinish) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\WorkflowElsa\WorkflowElsaSystem.cs:line 955
at AZO.KastorEngine.Systems.WorkflowElsa.WorkflowElsaSystem.TryResumeWorkflowInstance(Guid entityGuid, String bookmarkId, WorkflowState& workflowState, Dictionary`2 inputParameters, Boolean mustFinish) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\WorkflowElsa\WorkflowElsaSystem.cs:line 1007
at AZO.KastorEngine.Systems.WorkflowElsa.WorkflowElsaSystem.<>c__DisplayClass50_1.b__0() in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\WorkflowElsa\WorkflowElsaSystem.cs:line 1294
at AZO.KastorEngine.Systems.Entity.EntitySystem.WithTransaction(Action callback) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\Entity\EntitySystem.cs:line 590
--- End of stack trace from previous location ---
at AZO.KastorEngine.Systems.Entity.EntitySystem.WithTransaction(Action callback) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\Entity\EntitySystem.cs:line 689
at AZO.KastorEngine.Systems.Entity.EntitySystem.WithLockedTransaction(Action callback, Guid lockGuid, Boolean tryLock) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\Entity\EntitySystem.cs:line 568
at AZO.KastorEngine.Systems.WorkflowElsa.WorkflowElsaSystem.Execute() in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Systems\WorkflowElsa\WorkflowElsaSystem.cs:line 1288
at AZO.KastorEngine.EcsServiceWithoutTrans`2.Execute(ISystem system, IServiceScope serviceScope) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Infrastructure\EcsServiceWithoutTrans.cs:line 52
at AZO.KastorEngine.EcsHostedServiceBase`2.<>c__DisplayClass21_1.b__0() in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Infrastructure\EcsHostedServiceBase.cs:line 225
at AZO.Diagnostics.Debug.Trace(Action callback, String debugContext, String message, Object[] additionalParams, ITraceConfig config, Stopwatch stopwatch)
at AZO.KastorEngine.EcsHostedServiceBase`2.ExecuteIntern(CancellationToken cancellationToken) in C:\Work\Modules\Module_KastorEngine_VSCORE_Rev5022_WorkflowElsa33\src\AZO.KastorEngine\Infrastructure\EcsHostedServiceBase.cs:line 223

```

## Steps to Reproduce
Create the workflow above and try to suspend/resume the workflow with your possibilities within the Foreach iteration.

## Expected Behavior
The behaviour from 3.2.0 must be possible in 3.3.3, too. It was very easy, simply define all JSON data as object and never look back, cool.

Or what is the expected way to work with JSON objects and JSON arrays. Type JsonNode, type JSON, JsonElement, ....?

## Environment
- ELSA 3.3.3
- MongoDb persistation

Many thanks for your help!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.