elsa-workflows / elsa-workflows/elsa-core
[BUG] expressionExecutionContext.SetVariable() is not updating the variable value after upgrading from v3.1.3 to v3.2.0
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
## Description
I have an activity which evaluates an expression and assigns the result to the provided variable. I am storing all variables in the workflow context.
`context.GetWorkflowExpressionContext()!.SetVariable(varName, result);`
So if the variable is not available this will create a new one, otherwise it will update the value.
All these were working fine till I upgrade to Elsa **3.2.0**.
In Elsa **3.2.0**, the above line works fine only if the variable does not exists -> in that case, it creates the variable with the provided value.
If the variable is already available, this line silently fails, and not updating the variable with the new value.
We have used the SetVariable in multiple activities now lot of undesired behaviors are happening due to this silent failure. This is breaking the backward compatibility of the new version released. We have reverted the version for now.
## Steps to Reproduce
In any custom activity, lets try to create a variable using the below line and assign a value.
`context.GetWorkflowExpressionContext()!.SetVariable("myVariable","oldValue" );`
Now , in same activity or new activity, try to update the same variable with a new value using the same line.
`context.GetWorkflowExpressionContext()!.SetVariable("myVariable","newValue" );`
After the above update, check the workflow variable values -> the myVariable value will be still "oldValue"
5. **Reproduction Rate**: Indicate how often the bug occurs when following these steps (e.g., "every time", "intermittently: about 50% of the time").
This is not a random behavior. Always reproducible with the mentioned version.
## Expected Behavior
The SetVariable should behave exactly like before.
1) If variable is not available it should create with provided value
2) If available, it should update the value to new value.
## Actual Behavior
1) When the variable is already available in the context, SetVariable is not updating the value to new value. Also its not throwing any error.
## Environment
- **Elsa Package Version**: 3.2.0
- **Operating System**: Windows 11
Contributor guide
Assessment
This issue has not been assessed yet.