sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

DataInputSchema can only be a string and not an object

Open k-jay-c opened this issue 1 year ago • 7 comments

What happened: Trying to parse workflow definition with dataInputSchema defined as an object fails.

{
   "id": "greeting",
   "version": "1.0.0",
   "specVersion": "0.8",
   "name": "Greeting Workflow",
   "description": "Greet Someone",
   "start": "Greet",
   "dataInputSchema": {
      "schema": {
         "title": "Hello World Schema",
         "properties": {
            "person": {
               "type": "object",
               "properties": {
                  "name": {
                     "type": "string"
                  }
               },
               "required": [
                  "name"
               ]
            }
         },
         "required": [
            "person"
         ]
      }
   },
   "functions": [
      {
         "name": "greetingFunction",
         "operation": "file://myapis/greetingapis.json#greeting"
      }
   ],
   "states": [
      {
         "name": "Greet",
         "type": "operation",
         "actions": [
            {
               "functionRef": {
                  "refName": "greetingFunction",
                  "arguments": {
                     "name": "${ .person.name }"
                  }
               },
               "actionDataFilter": {
                  "results": "${ {greeting: .greeting} }"
               }
            }
         ],
         "end": true
      }
   ]
}

The above dataInputSchema is not accepted because in the code - this is only accepting a string.

What you expected to happen: As per the spec, the dataInputSchema can be a string or an object. Both should be accepted

How to reproduce it: Parse the above Workflow definition using sdk-go

Anything else we need to know?:

Environment:

  • Go version: go version go1.20.3 darwin/arm64

k-jay-c avatar Nov 28 '23 11:11 k-jay-c

Hi @k-jay-c! Thanks for reporting it. The code is not expecting a string, but a struct. The function to unmarshal should handle it as an object or string depending on the contents of the string:

https://github.com/serverlessworkflow/sdk-go/blob/main/util/unmarshal.go#L244

There might be a bug there. I don't have the pool to work on it atm, can you try sending a PR?

ricardozanini avatar Nov 28 '23 13:11 ricardozanini

Hi, I'll try to take a look on in this week on my spare time.

spolti avatar Nov 28 '23 15:11 spolti

Got it working, but one test is failing, will look into tomorrow :)

spolti avatar Nov 28 '23 22:11 spolti

Hi @k-jay-c, do you mind to test the changes in the attached PR?

spolti avatar Dec 01 '23 14:12 spolti

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 16 '24 00:01 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 02 '24 00:03 github-actions[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 19 '24 00:04 github-actions[bot]