8000 A writeproperty attempt is made even though parsing the input failed · Issue #119 · eclipse/editdor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
< 8000 !--$-->
A writeproperty attempt is made even though parsing the input failed #119
Open
@spf00

Description

@spf00

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.

Actual:
Image

const contentConverted = parseContent(propertyType, content);



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.

Actual:
Image

case "array":
let temp = stripDoubleQuotes(content);
if (Array.isArray(temp)) {
return temp;
}
try {
const parsedArray = JSON.parse(temp);
if (Array.isArray(parsedArray)) {
return parsedArray;
}
} catch {
throw new Error(`Error on convert "${content}" to an array.`);
}
case "object":
try {
return JSON.parse(stripDoubleQuotes(content));
} catch {
throw new Error(`Error on convert "${content}" to an object.`);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0