Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataInputSchema can only be a string and not an object #194

Closed
k-jay-c opened this issue Nov 28, 2023 · 7 comments · Fixed by #196
Closed

DataInputSchema can only be a string and not an object #194

k-jay-c opened this issue Nov 28, 2023 · 7 comments · Fixed by #196
Assignees
Labels
bug 🐛 Something isn't working

Comments

@k-jay-c
Copy link

k-jay-c commented Nov 28, 2023

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 k-jay-c added the bug 🐛 Something isn't working label Nov 28, 2023
@ricardozanini
Copy link
Member

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?

@spolti
Copy link
Member

spolti commented Nov 28, 2023

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

@spolti
Copy link
Member

spolti commented Nov 28, 2023

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

spolti added a commit to spolti/sdk-go that referenced this issue Nov 29, 2023
fixes serverlessworkflow#194

Signed-off-by: Spolti <filippespolti@gmail.com>
spolti added a commit to spolti/sdk-go that referenced this issue Nov 29, 2023
fixes serverlessworkflow#194

Signed-off-by: Spolti <filippespolti@gmail.com>
@spolti
Copy link
Member

spolti commented Dec 1, 2023

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

Copy link

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.

Copy link

github-actions bot commented Mar 2, 2024

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.

spolti added a commit to spolti/sdk-go that referenced this issue Apr 3, 2024
fixes serverlessworkflow#194

Signed-off-by: Spolti <filippespolti@gmail.com>
Copy link

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.

spolti added a commit to spolti/sdk-go that referenced this issue May 8, 2024
fixes serverlessworkflow#194

Signed-off-by: Spolti <filippespolti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants