mesg-foundation / engine

Build apps or autonomous workflows with reusable, shareable integrations connecting any service, app, blockchain or decentralized network.
https://mesg.com/
Apache License 2.0
130 stars 13 forks source link

Improve validate of task output #800

Closed NicolasMahe closed 5 years ago

NicolasMahe commented 5 years ago

Related to https://github.com/mesg-foundation/service-webhook/issues/4

Currently, it's possible to have an output data in the service definition like:

result: 
  description: "Result of the call the returns the list of the data from the API call result" 
  data: {} 

The core rejects when the result is emitted with error:

error: 'invalid output data error: json: cannot unmarshal string into Go value of type map[string]interface {}' }

The command service validate should reject to not have an data definition like this.

The proper output definition should be:

result: 
  description: "Result of the call the returns the list of the data from the API call result" 
  data:
    data:
      type: Object
krhubert commented 5 years ago

I think the 1st syntax is valid yaml with just data set to empty. How we should treat empty data in mesg definitoion?

How we should also represent that task/event don't return any data at all - there was issue created by @ilgooz about this somewhere but I don't remember where.

NicolasMahe commented 5 years ago

Actually you are right, it's a valid task definition.

The service that's do it actually send some data and it may be the reason of the error. I'm closing this issue because i also created one of the service's repo and will reopen if it's a bug in the core or not.