elsa-workflows / elsa-workflows/elsa-core

[BUG] Null Variables and Non-evaluating C#/JavaScript Expressions in Elsa Workflow Loaded from JSON

Open
#5,960 4 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

I am running a WinForms application and loading a workflow from a JSON file exported from Elsa Studio. The workflow runs successfully, but I am unable to use any workflow variables; they always return null. Additionally, any C# or JavaScript expressions I attempt to use do not evaluate, causing a runtime error.

The call stack reveals a NullReferenceException as shown below:

`Elsa.Workflows.Middleware.Activities.ExceptionHandlingMiddleware: Warning: An exception was caught from a downstream middleware component

System.NullReferenceException: Object reference not set to an instance of an object.
at Submission#4.<>d__0.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync(...)
at Elsa.CSharp.Services.CSharpEvaluator.EvaluateAsync(...)
at Elsa.CSharp.Expressions.CSharpExpressionHandler.EvaluateAsync(...)
at Elsa.Extensions.ActivityExecutionContextExtensions.EvaluateInputPropertiesAsync(...)
at Elsa.Workflows.Middleware.Activities.DefaultActivityInvokerMiddleware.InvokeAsync(...)
`

**Steps to Reproduce**

1. Load a workflow exported from Elsa Studio in a WinForms application.
2. Attempt to use workflow variables or evaluate C#/JavaScript expressions within the workflow.
3. Observe that the workflow completes but variables are null and expressions do not evaluate.

**Expected Behavior**
Variables should be accessible and return valid values, and C# or JavaScript expressions should evaluate correctly during the workflow execution.

**Actual Behavior**
Variables always return null and expressions are not evaluated, leading to a NullReferenceException in the workflow execution.

**Log Output**
Logs show the following warning message related to the null reference error:

`Elsa.Workflows.Middleware.Activities.ExceptionHandlingMiddleware: Warning: An exception was caught from a downstream middleware component

System.NullReferenceException: Object reference not set to an instance of an object.
`

**Additional Context**
This issue only occurs when running the workflow from a JSON file exported from Elsa Studio in Winfrom Application. The same expressions and variable manipulations work correctly when run on elsa server.

https://v3.elsaworkflows.io/docs/guides/loading-workflows-from-json
this is Code i m using in my Winfrom Aplication.

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.