-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-validating value() function #554
Comments
One thing to consider is that we designed the About default, I think that the function should validate as the current behavior is always validated. Changing this would be a very sneaky move. Image that you are expecting the function to always return well formed data and later in mid of your application you find that a field is missing or is an number instead of a boolean. |
@relu91 If I read your comment correctly you suggest the following way forward
I am fine with this way forward even though I think it is clearer to have |
Yes, I'm suggesting that path forward but I'm open to other opinions too, I think in the end it's a matter of taste and developer background. For web developers looking for the |
In a browser API there would be no way to skip validation, for security reasons. |
Skipping validation is already possible, the newly introduced function (or option) would just be a shortcut for: // output is an InteractionOutput instance
const value = JSON.parse(Buffer.from(await output.arrayBuffer()).toString()) But I agree that adding text about possible threats regarding the practice of avoiding validation is something we should do. |
Call 2024-08-05:
|
I'm pretty sure you meant August 5 (not May 9, not September 5). Best to use ISO8601 format, e.g., 2024-08-05, especially but not only for such potentially ambiguous dates. |
Thanks! updated. |
On this topic, I went back to looking at the latest TD recommendation document and I found this assertion:
If I read it right this means that the cases where we are "getting the value even if it does not validate" are buggy, meaning that we are perpetuating something already wrong. For reference that section adds also some other assertions on how Consumers should behave when interacting with a remote Thing:
I think we might still have the "performance" use case for introducing the |
Given the new information above, we might want to reconsider not introducing a new function but rather mention the alternatives like this one. I'll work on a concrete PR. |
I agree with this. The only possible cases are unexpected states of a Thing where the TD would explode trying to describe all possible error values and the TD designer takes a "shortcut" by providing an underspecified TD. |
Based on the discussion in eclipse-thingweb/node-wot#1279 two points/issues arose. One is the following.
The current
value()
function ofInteractionOutput
requires as step 10 to validate the value.I think there are good use-cases to avoid doing validation
Note: I think the current requirement to MUST validate the data reported is also very heavy in a sense. I think there are (and will be) implementations out there that simply do not have the power to validate the data (no JSON schema library available etc).
I wonder how we can account for that? Say it is best effort only?
Anyhow, in the thingweb committer call we had the feeling that we should at least extend the current value function in a way that the user of the API can decide whether validation is done or not. This could be done in a backwards compatible way changing the current signature of
Promise<DataSchemaValue> value();
to something like
Yet another question is what the default behavior of
validate
should be?The text was updated successfully, but these errors were encountered: