eclipse-thingweb / node-wot

Components for building WoT devices or for interacting with them over various IoT protocols
https://thingweb.io
Other
161 stars 78 forks source link

action and event affordance do not raise error when data schema does not match #1280

Open VigneshVSV opened 3 months ago

VigneshVSV commented 3 months ago

I have an action with the following schema:

"sample_get_method": {
      "title": "sample_get_method",
      "forms": [
        {
          "href": "https://LAPTOP-F60CU35D:8083/spectrometer/ocean-optics/USB2000-plus/get-example",
          "op": "invokeaction",
          "htv:methodName": "GET",
          "contentType": "application/json"
        }
      ],
      "safe": true,
      "idempotent": true,
      "synchronous": true
    },

When i invoke this action in node-wot


console.log("action with return value", await spectrometer.invokeAction("sample_get_method"));
console.log("action with return value awaited", await (await await spectrometer.invokeAction("sample_get_method").value())

here the spectrometer object refers to the node-wot client which I create after consuming the TD.

I get the output

action with value InteractionOutput {form: {…}, schema: undefined, dataUsed: false}
action with value undefined

I was told it would be better if it throws an error similar to how readProperties work - to complain that the schema didnt match.

the td-playground validator does not also complain the absence of input/output schema i.e. td is accepted, but action (also event) reply dont produce error because schema is not matching due to its absence?

VigneshVSV commented 3 months ago

td.json

May not be here but full TD is attached & node-wot client is here

Also the current TD document says that input and output schema are optional, it was part of the reason why I generated action affordance without these fields.

For reference to others - Secondly, as I explained to Chris & Ege, my TD is from my server side package. The TD is auto-generated based on python code as my package has average to above-average resemblance to the properties, events and actions of WoT. I would appreciate if the end-user did not have to bother about generating schemas because their knowledge level might be low; yet, on the other, auto-generating a schema is not straightforward. So the option to access the return value of actions must be present without the botheration of a schema.

VigneshVSV commented 1 month ago

Hi, any update on this?

danielpeintner commented 1 month ago

Just for clarification. The TD does not mention any output for the action, right? The server code returns data or does not return any data? I am not 100% sure about the problem nor about the expectation...