elsa-workflows / elsa-workflows/elsa-core

Activity with Javascript input throw Exception when Workflow Variables are set

Open
#3,261 0 comments 0 reactions 0 assignees View on GitHub
bug triaged
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

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.