Description
Because parseContent catches any conversion errors and doesn't throw an error or return the error status to the caller, it returns undefined
to the writeProperty function, which continues with its operation and sends undefined
to the target server of the TD.
This in turn leads to the ediTDor showing an "Internal server error", which is wrong in this case.
Reproduce:
Use http://plugfest.thingweb.io/http-data-schema-thing (enable mixed content for editdor) and call writeproperty on e.g. the "Int" property with a string input, e.g. "abc".
Expected:
User gets notified that "abc" is not parseable into an int.
What I also noticed: There are no breaks inbetween the cases of the parseContent switch. This is fine for most cases because they either return or throw an error. When failing to parse an array though (e.g. when the input is "1" instead of an array), the function "falls" from the "array" case into the "object" case, maybe even succeeds to parse the input as JSON (when using "1" this is the case) and writeproperty
attempts a request with this parsed JSON.
@TejInaco is this behavior intended?
Reproduce:
Use http://plugfest.thingweb.io/http-data-schema-thing (enable mixed content for editdor) and call writeproperty on the "Array" property with input "abc".
Expected:
User gets notified that "abc" is not parseable into an array.
editdor/src/components/TDViewer/components/Form.jsx
Lines 130 to 150 in 95c20ef