eclipse-thingweb / node-wot

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

Issue with void-obj of Test Thing #1289

Open egekorkan opened 1 month ago

egekorkan commented 1 month ago

I have noticed a weird behavior with test thing. I have taken the td at http://plugfest.thingweb.io:8083/testthing and generated the flow. Everything but the following actions work: int-void, int-int, int-string. For those ones, I get nothing displayed on the UI but the flow editor shows internal server error. Sending the same request on postman, for example for int-int with input 12 returns 13. Action void-obj does exactly what I expect.

The error is Error: Server error: Internal Server Error

Originally posted by @egekorkan in https://github.com/eclipse-thingweb/node-red/issues/25#issuecomment-2125677188

danielpeintner commented 1 month ago

Mhh, can it be that there is no input given?

I tested the following simple script with 3 simple invokeAction calls.

WoT.requestThingDescription("http://plugfest.thingweb.io:8083/testthing")
    .then(async (td) => {
        try {
            const thing = await WoT.consume(td);
            // console.info("=== TD ===");
            // console.info(td);
            // console.info("==========");
            // console.info();

            // int-void
            {
                const res = await thing.invokeAction("int-void", 123);
                const value = await res.value();
                console.info("RESPONSE for int-void: ", value);             
            }
            // int-int
            {
                const res = await thing.invokeAction("int-int", 453);
                const value = await res.value();
                console.info("RESPONSE for int-int: ", value);              
            }

            // this is failing because there is no input as expected 
            // int-void (with no input)
            {
                const res = await thing.invokeAction("int-void"); // , 123);
                const value = await res.value();
                console.info("RESPONSE for int-void: ", value);             
            }

        } catch (err) {
            console.error("Script error:", err);
        }
    })
    .catch((err) => {
        console.error("Fetch error:", err);
    });

The console log is as follows.

node packages\cli\dist\cli.js --client-only examples\testthing\testclient2.js
RESPONSE for int-void:  undefined
RESPONSE for int-int:  454
Script error: Error: Server error: Internal Server Error

As long as I pass the input value to the invokeAction call everything is fine. Once I don't do that I get the same error...