elsa-workflows / elsa-workflows/elsa-core

[BUG] Error when Set Variable from Json data

Open
#5,905 3 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

## Description

Set Variable it is not working when you try to set a value from a HttpRequest response

## Steps to Reproduce

![image](https://github.com/user-attachments/assets/c86edd78-79e7-4ce4-8393-47616743e156)

- Create an workflow definition
- Add a http request and save the parsedcontent in a variable of type Json(dynamic)

![image](https://github.com/user-attachments/assets/2f53428f-b88c-402f-bc00-07a50c8d1a73)

Following json returned from the http request

`{"results":[{"id":1,"name":"Item A"},{"id":2,"name":"Item B"},{"id":3,"name":"Item C"}]}`

- Add a set varaible after the http request, using a c# expression to get the property of the json
`dynamic responseFromHttp = Variables.JsonData;

return responseFromHttp.results;`

![image](https://github.com/user-attachments/assets/1777388b-d153-432d-8ebd-497e44814188)

when execute give the following erro: (3,8): error CS0656: Member “Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create” required by missing compiler

stack trace

at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.ThrowIfAnyCompilationErrors(DiagnosticBag diagnostics, DiagnosticFormatter formatter) at Microsoft.CodeAnalysis.Scripting.ScriptBuilder.CreateExecutor[T](ScriptCompiler compiler, Compilation compilation, Boolean emitDebugInformation, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Scripting.Script`1.GetExecutor(CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Scripting.Script`1.RunAsync(Object globals, Func`2 catchException, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.Scripting.Script`1.RunAsync(Object globals, CancellationToken cancellationToken) at Elsa.CSharp.Services.CSharpEvaluator.EvaluateAsync(String expression, Type returnType, ExpressionExecutionContext context, ExpressionEvaluatorOptions options, Func`2 configureScriptOptions, Func`2 configureScript, CancellationToken cancellationToken) at Elsa.CSharp.Expressions.CSharpExpressionHandler.EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext context, ExpressionEvaluatorOptions options) at Elsa.Expressions.Services.ExpressionEvaluator.EvaluateAsync(Expression expression, Type returnType, ExpressionExecutionContext context, ExpressionEvaluatorOptions options) at Elsa.Extensions.ActivityExecutionContextExtensions.EvaluateInputPropertyAsync(ActivityExecutionContext context, ActivityDescriptor activityDescriptor, InputDescriptor inputDescriptor) at Elsa.Extensions.ActivityExecutionContextExtensions.EvaluateInputPropertiesAsync(ActivityExecutionContext context) at Elsa.Workflows.Middleware.Activities.DefaultActivityInvokerMiddleware.EvaluateInputPropertiesAsync(ActivityExecutionContext context) at Elsa.Workflows.Middleware.Activities.DefaultActivityInvokerMiddleware.InvokeAsync(ActivityExecutionContext context) at Elsa.Workflows.Middleware.Activities.NotificationPublishingMiddleware.InvokeAsync(ActivityExecutionContext context) at Elsa.Workflows.Middleware.Activities.ExecutionLogMiddleware.InvokeAsync(ActivityExecutionContext context) at Elsa.Workflows.Middleware.Activities.ExceptionHandlingMiddleware.InvokeAsync(ActivityExecutionContext context)

3. **Attachments**:
Included the workflow definition
[request.json](https://github.com/user-attachments/files/16626239/request.json)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the workflow from the attached request.json: an HttpRequest stores parsed JSON, then Set Variable evaluates the C# expression using Variables.JsonData. Trace the reported Elsa.CSharp.Services.CSharpEvaluator and Elsa.CSharp.Expressions.CSharpExpressionHandler entry points to identify why dynamic access lacks the runtime binder; done means responseFromHttp.results evaluates successfully without CS0656.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.