|
Post by AMI_Mani on Jun 11, 2021 17:59:51 GMT
Hi, As per base registry we have following message for invalid property value
"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."
Assume user is patching with empty array, empty object, array of empty object(along with many valid properties and using empty for few) for String data type, it's not possible to show the actual value provided in request. Sometime user may give double quotes, single quotes and other special characters which may not be shown as it is in %1 of message
Can we have one standard message mentioning propertyvaluetype is incorrect by adding property alone(without property value) or any other standard message exists to handle this negative case scenario in request processing?
Thanks, Mani
|
|
|
Post by jautor on Jun 14, 2021 17:52:07 GMT
I'll bring this up with the group, but I wonder if it would be better to keep a single message for all these cases and just use "best effort" to show the value? Inserting <null>, <empty>, <invalid string> or some other indication of "this isn't the actual value, but a representation" could be simpler than adding more subtle variations of this message.
I looked to see if there was another message that would work, and I don't see one - all of other property/value messages have two parameters - so it may make sense to add one with just the property as the only parameter to cover any of the edge cases where the value can't or shouldn't be included in the message.
Jeff
|
|
|
Post by AMI_Mani on Jun 14, 2021 18:14:16 GMT
Hi Jeff, We can use like null/empty array/empty object/invalid data type(many more will add up) as generic value instead of getting the value from request which can solve the issue. But if we add one generic message in Base using only property alone , it will be good for future use.
Another option is to provide Property name, property data type allowed(data type) alone in message args instead of parsing value provided in request body(where the value can't or shouldn't be included in the message)
Thanks, Mani
|
|
|
Post by jautor on Jun 15, 2021 23:40:43 GMT
We discussed this today and the group agreed that a more general message with a single parameter (the property name), for cases where including the value may be problematic, would be an appropriate addition. We'll add it to the next release.
Jeff
|
|
|
Post by AMI_Mani on Jun 18, 2021 3:28:27 GMT
Thanks for adding to next release.
Thanks, Mani
|
|
|
Post by AMI_Mani on Aug 2, 2021 7:39:24 GMT
Hi Jeff,
Can we have one standard message mentioning propertyvaluetype is incorrect by adding property (without property value) with correct data type like or any other standard message exists to handle this negative case scenario in request processing?
Expecting to provide Property name, property data type allowed(data type) alone in message args instead of parsing value provided in request body(where the value can't or shouldn't be included in the message). This message helps user in providing proper data type in request instead of checking schema
Data type can be "array", "boolean", "integer", "number", "null", "object", "string"
Sample message "The value for the property %1 is of a different type than the property can accept, the allowable data type is %2."
(here 1% refers Property Name , %2 refers allowable data type of the property)
Thanks, Mani
|
|
|
Post by AMI_Mani on Nov 5, 2022 17:15:41 GMT
Hi Jeff, We are able to see PropertyValueError message addition in redfish.dmtf.org/registries/Base.1.11.0.json and thanks for adding that. I have a clarification related to returning two different messaes based on request body and would like to know whether this is ok in implementation Assume user is patching AssetTag which is string and request body for patch request as below Use case 1 "AssetTag": "{test{test1}}" Above request data can contain/nested objects/nested array and mainly targeting invalidat data. For above request returning bad request with PropertyValueError as response Use case 2"AssetTag": true Above request data can different direct data type like boolean, numbers and mainly targeting invalidat data. For above request returning bad request with PropertyValueTypeError since service is able to print property vale in message For same URI patch with same attributes, returning two error messages based on request data. Do we need service implementation to return uniform message(PropertyValueError) always irrespective of request body or show different mesage(PropertyValueError/PropertyValueTypeError) based on request body? Thanks, Mani
|
|
|
Post by jautor on Nov 7, 2022 20:29:01 GMT
For same URI patch with same attributes, returning two error messages based on request data. Do we need service implementation to return uniform message(PropertyValueError) always irrespective of request body or show different mesage(PropertyValueError/PropertyValueTypeError) based on request body? Mani, No, I would recommend returning the most specific error message available. These messages are all intended for the client / user - giving them as much information as possible so they can resolve the issue. While "bad value" is an accurate description, returning "bad JSON type" is more descriptive... Jeff
|
|
|
Post by Caffrey on Nov 8, 2022 14:41:21 GMT
We discussed this today and the group agreed that a more general message with a single parameter (the property name), for cases where including the value may be problematic, would be an appropriate addition. We'll add it to the next release. Jeff Hi Jeff, Thanks for the prompt reply. I would like to explain some more details. I think the group helped to add the general message PropertyValueError that can apply to different cases and its very useful. The actual problem @mani and I have right now is for same type of invalid input, do we allow to use different messages or shall use single one is better. For example, user try to PATCH a property with invalid data type values. We use "AssetTag" (string) as example here and assume user try to give following invalid values. PATCH A - {"AssetTag": true} B - {"AssetTag": 123} C - {"AssetTag": ["a", "b", "c"]} D - {"AssetTag": {"a": 123}} For case A and B, Redfish returns PropertyValueError For case C and D, Redfish returns PropertyValueTypeError. The question here is A, B, C and D all are invalid type input cases. Is above implementation ok? or we shall pick only one to use is better? Please share your thoughts. Many thanks. Caffrey
|
|
|
Post by AMI_Mani on Nov 8, 2022 17:24:46 GMT
Hi Jeff, Thanks for the details. I agree that Service implementation can give different error message for same resource URI operation based on request data which can help user to rectify the error quickly to resubmit. Please reply for post added by Caffrey also
Thanks, Mani
|
|
|
Post by jautor on Nov 8, 2022 22:19:26 GMT
Caffrey's four cases are technically all "type errors" (since none of those are strings) - but my answer will be the same, regardless.
Either of those messages are accurate, and what you return may be dependent on how the code works (and likely depends on the language used and libraries involved). In the case above, it may be that since C and D are array/object types that they cause a different code path than the A or B cases which are single values but wrong data type.
So if the code detects one error condition (wrong data type) in some cases, but another error condition in others, that's fine. In all those cases, the results will be the same, with the same HTTP response code and fixes needed in the request.
Jeff
|
|
|
Post by Caffrey on Nov 10, 2022 0:44:44 GMT
Caffrey's four cases are technically all "type errors" (since none of those are strings) - but my answer will be the same, regardless. Either of those messages are accurate, and what you return may be dependent on how the code works (and likely depends on the language used and libraries involved). In the case above, it may be that since C and D are array/object types that they cause a different code path than the A or B cases which are single values but wrong data type. So if the code detects one error condition (wrong data type) in some cases, but another error condition in others, that's fine. In all those cases, the results will be the same, with the same HTTP response code and fixes needed in the request. Jeff Hi Jeff, Got it. We appreciate your help very much. BR, Caffrey
|
|