Closed wissemEddineSouilhi closed 3 months ago
Thanks for reporting the issue @wissemEddineSouilhi!
I'm sorry I totally overlooked that issue, which is now stale since https://github.com/serverlessworkflow/sdk-net/tree/v1.0.0-alpha1.
If you're up to it, you can open PR to address the bug and I'll merge it into 0.8.6.
I encountred a problem when creating a serverlessWorkflow using the Serverless Workflow .NET SDK and i have found a temporary solution so i wanted to report it.
Problem : I Wanted to create a simple ServerlessWorkflow with an Action that contain a fromStateData, so I used the method FromStateData when defining the actionBuilder . When The method Execute of The operationStateBuilder is executed a NullReferenceException has thrown.
Message : Object reference not set to an instance of an object . StackTrace : at ServerlessWorkflow.Sdk.Services.FluentBuilders.ActionBuilder.FromStateData(String expression) in ServerlessWorkflow.Sdk.Services.FluentBuilders\ActionBuilder.cs:line 33
I checked the code of Serverleswokflow.D=Sdk and I don't see any initialisation of the property ActionDataFilter of the class ActionDefinition.
To reproduce the problem just create a simple workflow with action that have have FromStateData.
Environment: I'm working with Serverless Workflow .NET SDK version 0.8.4 with .Net 8 in windows 11 and visual studio 2022 Note : In the latest version there is an issue that is already reported that prevent the application from starting this is whay i used this version and because it 's used by Synapse. But as i see the problem persist in the latest version (There is no initialisation).
Temporary Solution As a solution i created an extension method for the interface IActionBuilder that initialise the property ActionDataFilter of the ActionDefinition .
This method must be called one time before calling any of FromDataState or ToStateData or FilterResults Methods when creating an actionBuilder.
Working Code :
Result :
{ "id": "workflowid", "name": "workflowtest", "version": "1.0", "specVersion": "0.8", "events": [ { "name": "cloudevent1", "source": "htpp://localhost:5000/test", "type": "localhost.domain.com" } ], "functions": [ { "name": "testfunction", "operation": "http://localhost:5024/api/swagger/swagger.Json", "type": "rest" } ], "start": "cloudEvent", "states": [ { "name": "cloudEvent", "type": "event", "onEvents": [ { "actions": [], "eventRefs": [ "cloudevent1" ], "eventDataFilter": {} } ] }, { "type": "operation", "actions": [ { "name": "action1", "actionDataFilter": { "fromStateData": "${ .}" }, "functionRef": { "refName": "testfunction" } } ], "end": true } ] }