elsa-workflows / elsa-workflows/elsa-core
Activity with Javascript input throw Exception when Workflow Variables are set
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
# Using
- .NET 6
- Elsa 2.8.2
# Steps to reproduce
Create a workflow with the designer and set the Workflow Variables as follow :
```json
{
"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](https://github.com/elsa-workflows/elsa-core/files/9382149/activity.zip)
# Expected
An exception of type `Elsa.Exceptions.CannotSetActivityPropertyValueException` must be thrown.
```json
{
"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.
Contributor guide
Assessment
This issue has not been assessed yet.