danielgerlag / danielgerlag/workflow-core

When using YAML / JSON workflow definition, input type is forced to JObject

Open
#1,298 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
5.9k
Forks
1.3k
Avg merge
1d 1h
Merged PRs (30d)
5

Description

**Describe the bug**
When using yaml / json workflow definition, `DefinitionLoader.BuildObjectInputAction` method will convert dictionary to JObject.
Which means we can't use dictionary as the input type in any step class. Basically https://github.com/danielgerlag/conductor/blob/master/src/Conductor.Steps/HttpRequest.cs#L21 won't work with yaml definition.

**To Reproduce**
The following yaml will fail since Headers section will be converted to JObject.
```
StepType: Conductor.Steps.HttpRequest, Conductor
Inputs:
BaseUrl: '"https://reqres.in/"'
Resource: '"/api/login"'
Method: '"POST"'
Headers:
"@apiKey": environment["LOGNAME"]
```

**Expected behavior**
Dictionary type input should work with yaml workflow definition.

**Additional context**
Error message:
```
Object of type 'Newtonsoft.Json.Linq.JObject' cannot be converted to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.
```

Stacktrace:
```
at System.RuntimeType.CheckValue(Object& value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at WorkflowCore.Services.DefinitionStorage.DefinitionLoader.<>c__DisplayClass12_0.g__acn|0(IStepBody pStep, Object pData, IStepExecutionContext pContext)
at WorkflowCore.Models.ActionParameter`2.Assign(Object data, IStepBody step, IStepExecutionContext context)
at WorkflowCore.Models.ActionParameter`2.AssignInput(Object data, IStepBody body, IStepExecutionContext context)
at WorkflowCore.Services.WorkflowExecutor.ExecuteStep(WorkflowInstance workflow, WorkflowStep step, ExecutionPointer pointer, WorkflowExecutorResult wfResult, WorkflowDefinition def, CancellationToken cancellationToken)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in DefinitionLoader.BuildObjectInputAction and inspect how the YAML example's Headers value is assigned to Conductor.Steps.HttpRequest, referenced in HttpRequest.cs. Reproduce the workflow with the supplied definition and verify that a dictionary input works without the JObject conversion error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.