|
Post by abiramisekar on Jun 17, 2021 17:12:30 GMT
Hi,
I am trying to Patch PowerControl Property inside Power URL, with the request body as 1. {"PowerControl": 123} whether we need throw error as PropertyValueTypeError or PropertyNotWritable?
Under PowerControl property, PowerLimit is writable, valid Request body is { "PowerControl": [ { "PowerLimit": { "CorrectionInMs": 1500, "LimitException": "HardPowerOff", "LimitInWatts": 500 } } ] }
2. {"Status": ""} whether we need to throw error as PropertyValueTypeError or PropertyNotWritable?
Under Status all the sub Properties are Readonly, {"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
}}
if we give request body like , {"Status": {
"Abc":"led"
}} do we need to handle this error like Property Unknown for "Abc" or we can give Property Not writable for "Status"
Please Clarify on this.
Thanks, Abirami S
|
|
|
Post by mraineri on Jun 22, 2021 14:07:13 GMT
For your first case, PropertyValueTypeError is the proper response to use. In this case, PowerControl is provided by the client in an incorrect format, and there are properties inside of PowerControl that could be modified.
For your second case, this is a bit ambiguous; at the "Status" level we do not define whether or not the object itself is writable or read-only. All properties inside of "Status" today are defined as read-only. I would suspect this needs to be handled in a layered approach; first the client needs to be told that the format of the property is not correct (PropertyValueTypeError), and then once the format is corrected by the client, it would encounter PropertyNotWritable messages since properties like Health are read-only.
|
|
|
Post by ginugeorge on Jun 23, 2021 6:02:12 GMT
Hi mraineri As per your suggestion, when the user provides a request body as below, { "Status": "" } We should be throwing " PropertyValueTypeError" Error since Status attribute needs to be an object-type value and is rather provided as a string in the request body and I agree to it. But, when the user provides a request body as below, { "Status": {
"Abc":"led"
} } Status attribute does have an object-type value as per schema. But there is an unknown attribute named "Abc". Wouldn't it make sense to throw "PropertyUnknown" Error ("Indicates that an unknown property was included in the request body.") ? Or should be skip such cases and throw "PropertyValueFormatError" Error ("Indicates that a property was given the correct value type but the value of that property was not supported.") instead ? Please suggest. Attaching few Message registries for reference purpose : ["PropertyUnknown"] = { ["Description"] = "Indicates that an unknown property was included in the request body.", ["Message"] = "The property %1 is not in the list of valid properties for the resource.", ["Severity"] = "Warning", ["NumberOfArgs"] = 1, ["ParamTypes"] = { "string" }, ["Resolution"] = "Remove the unknown property from the request body and resubmit the request if the operation failed." }, ["PropertyValueTypeError"] = { ["Description"] = "Indicates that a property was given the wrong value type, such as when a number is supplied for a property that requires a string.", ["Message"] = "The value %1 for the property %2 is of a different type than the property can accept.", ["Severity"] = "Warning", ["NumberOfArgs"] = 2, ["ParamTypes"] = { "string", "string" }, ["Resolution"] = "Correct the value for the property in the request body and resubmit the request if the operation failed." }, ["PropertyValueFormatError"] = { ["Description"] = "Indicates that a property was given the correct value type but the value of that property was not supported.", ["Message"] = "The value %1 for the property %2 is of a different format than the property can accept.", ["Severity"] = "Warning", ["NumberOfArgs"] = 2, ["ParamTypes"] = { "string", "string" }, ["Resolution"] = "Correct the value for the property in the request body and resubmit the request if the operation failed." }
|
|
|
Post by jautor on Jun 24, 2021 16:20:44 GMT
But, when the user provides a request body as below, { "Status": { "Abc":"led" } } Status attribute does have an object-type value as per schema. But there is an unknown attribute named "Abc". Wouldn't it make sense to throw "PropertyUnknown" Error ("Indicates that an unknown property was included in the request body.") ? Or should be skip such cases and throw "PropertyValueFormatError" Error ("Indicates that a property was given the correct value type but the value of that property was not supported.") instead ? Please suggest. In each of the cases you've mentioned, there are multiple errors with the request, so returning any one of those is valid - and it will very likely depend on your web framework and implementation which one will get used. So I think we can suggest what would be the "most useful" for the client, but looking at these cases, they are all errors in code logic that will have to be fixed in the client code. So it really doesn't matter which error is returned - because it all needs to be fixed! For this last case, that's an unknown property, so "PropertyUnknown" is the best answer. But since `Status` is a read-only object, `PropertyNotWriteable` would also be valid. But I think the more useful error is the unknown property - because it's either a typo in the name, or it's pointing at the wrong object. Jeff
|
|