elsa-core
elsa-core copied to clipboard
Activity with Javascript input throw Exception when Workflow Variables are set
Using
- .NET 6
- Elsa 2.8.2
Steps to reproduce
Create a workflow with the designer and set the Workflow Variables as follow :
{
"RequiredParameters": [
"ManagerEmail"
]
}
Then add a Console Write Line activity with the Text property set as Javascript with the value correlationId
.
You can also import the json workflow that I made (with an HTTP Endpoint activity to easily start the workflow from /with-javascript
).
activity.zip
Expected
An exception of type Elsa.Exceptions.CannotSetActivityPropertyValueException
must be thrown.
{
"Type": "Elsa.Exceptions.ExpressionEvaluationException",
"Message": "Failed to evaluate expression",
"StackTrace": "[...]",
"InnerException": {
"Type": "System.InvalidCastException",
"Message": "Unable to cast object of type 'System.String' to type 'System.Dynamic.ExpandoObject'.",
"StackTrace": "[...]",
"InnerException": null,
"Data": {}
},
"Data": {
"Expression": "correlationId",
"Syntax": "JavaScript"
}
}
Note
We can see this behavior only when an activity input is set from Javascript.
I made the test from Liquid with the value {{ CorrelationId }}
and it works well.
So maybe whenever the workflow try to evaluate Javascript it also try to parse the Workflow Variables and for some reason an exception is thrown when it contain an array of string.