sdk-go
sdk-go copied to clipboard
DataInputSchema can only be a string and not an object
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
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?
Hi, I'll try to take a look on in this week on my spare time.
Got it working, but one test is failing, will look into tomorrow :)
Hi @k-jay-c, do you mind to test the changes in the attached PR?
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.
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.
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.