|
Post by striker on Sept 2, 2024 15:37:14 GMT
Hi. Should each element of the array be checked before changing the entire array? For example, I want to change an IPv4StaticAddresses property by performing PATCH request with the following JSON:
[ { "Address": "10.10.10.10", "Gateway": "10.10.10.250", "SubnetMask": "255.255.255.0" }, { "Address": "10.10.1000.10", "Gateway": "10.10.1000.250", "SubnetMask": "255.255.255.0" }, { "Address": "11.11.11.11", "Gateway": "11.11.11.250", "SubnetMask": "255.255.255.0" }, ]
What is the expected behavior in this case?
1) No changes. Should send the PropertyValueIncorrect (or some other message). 2) The resulting array contains only the 1st element (the 2nd and 3rd are ignored). Should some kind of error be sent? 3) The resulting array contains the 1st and 3rd elements (the 2nd is ignored). Should some kind of error be sent?
|
|
|
Post by mraineri on Sept 3, 2024 17:23:03 GMT
The specification is open in this regard. Today it doesn't dictate a particular validation approach. Some services could perform up-front validation to flag bad requests and fall into case #1. Others might pass this off to lower layers, which would allow for some properties to change, but others to fail. This latter scenario could result in either cases #2 or #3 depending on the design of the service. In cases #2 and #3, you would get back a 200 OK with messages in the response that indicate which properties could not be updated; this is described as the "partial success" condition.
|
|
|
Post by striker on Sept 5, 2024 16:57:42 GMT
Could you please explain the following? PATCH request contains only one property of the array type ( IPv4StaticAddresses). Thus, in the case of #2 and #3, we get a situation where the property has been updated, but partially. I know that " Address", " Gateway", " SubnetMask" are also properties. But properties of nested JSON objects. Could you please give an example of Redfish response in #2 and/or #3?
|
|
|
Post by mraineri on Sept 5, 2024 19:59:40 GMT
This would be for case 3 where all the properties in the request for the first and third members were accepted and applied. I'm also assuming "SubnetMask" was successfully applied for the second member.
{ "@Message.ExtendedInfo": [ { "MessageId": "Base.1.8.PropertyValueFormatError", "Message": "The value '10.10.1000.10' for the property Address is not a format that the property can accept.", "Severity": "Warning", "MessageSeverity": "Warning", "RelatedProperties": [ "/IPv4StaticAddresses/1/Address" ] }, { "MessageId": "Base.1.8.PropertyValueFormatError", "Message": "The value '10.10.1000.250' for the property Gateway is not a format that the property can accept.", "Severity": "Warning", "MessageSeverity": "Warning", "RelatedProperties": [ "/IPv4StaticAddresses/1/Gateway" ] } ], "Id": "eth0", "Name": "Ethernet Interface eth0", ... <Other EthernetInterface properties> }
For case #2, there should be additional messages to indicate the service did not process the request for the third member (the first member was applied, and the second member encountered errors and thus stopped the processing). "PropertyNotUpdated" would be the best match for pointing to the properties of the third member that were skipped.
|
|
|
Post by malbolge on Sept 16, 2024 15:38:26 GMT
I'll attach here since I'm running into a very similar issue with ConfiguredSpeedGbps.
DSP0266 says:
The nuance comes in when the payload is complex.
Here, the user is attempting to modify "IPv4StaticAddresses", with a complex payload, consisting of Collection(IPAddresses.IPv4Address) - encoded in JSON as an anonymous array of IPv4Address objects.
Let's assume the user is PATCHing the payload the original poster supplied:
{ //snip
"IPv4StaticAddresses": [ { "Address": "10.10.10.10", "Gateway": "10.10.10.250", "SubnetMask": "255.255.255.0" }, { "Address": "10.10.1000.10", "Gateway": "10.10.1000.250", "SubnetMask": "255.255.255.0" }, { "Address": "11.11.11.11", "Gateway": "11.11.11.250", "SubnetMask": "255.255.255.0" }, ]
// snip }
How many properties are being PATCHED here? A) Only one property is being updated - the entire IPv4StaticAddresses array, it's children and it's contents constitute a single property update to the "IPv4StaticAddresses" property. B) Three properties are being updated - each instance of IPv4Address in the array is counted as an atomic property write, as the application of a complex object needs to be considered in it's entirety C) Nine properties are being updated - repeated instances of Address, Gateway and SubnetMask are the most fundamental components of the request that hold the meaningful data E) Combinations of above, eg. A+B or B+C or A+B+C
DSP0266 defines behavior for partial successes of multiple properties, but does not define behavior for partial success within a single property update. Understanding whether this is a single property update or multiple property update is key to identifying whether DSP0266's partial success clauses apply.
My understanding is that when considering a single property update, it can either be: Entirely successful - in which case for anything that's not volatile (counters, modified externally etc), the user should expect to see exactly (disregarding linting, string escapes...) what he put in the input payload upon reading it back OR Failed entirely with no changes being made to the property that caused the failure, but without necessarily failing the entire PATCH operation, unless all properties of the operation are failed.
In both the case of IPv4StaticAddresses and my case, ConfiguredSpeedGbps, the most sensible option appears to be B - that complex objects are considered atomic. This would allow the device to accept some IPv4Address objects, reject others, and return success if at least one IPv4Address stuck.
Alternatively there's option A, exactly all three IPv4Address must get applied verbatim, or nothing changes. (a single invalid SubnetMask in a single IPv4Address would cause the whole thing to fail with no effect)
Option C appears the most risky - suppose I supply a bad Address and a bad SubnetMask but a good Gateway. I'd end up with an old/unchanged Address, old/unchanged SubnetMask, new Gateway, and PATCH success.
Looking forward to this forum's input.
|
|
|
Post by mraineri on Sept 27, 2024 19:14:17 GMT
In this case, it's really 9 properties (C). While there is an upper level property (IPv4StaticAddresses) and there an array of objects, the user is still attempting to modify 9 discrete values. Even if we were to flatten the resource and just stick things like "Address0", "Gateway0", SubnetMask0", etc all at the root, we'd still have the same issue where there's a mix of old/unchanged properties due to various error conditions. This might be a case where an implementer might prefer to perform upfront checks on requests like this to fail the request entirely to avoid the partial success outcomes.
|
|
|
Post by malbolge on Oct 2, 2024 13:41:19 GMT
Thanks! So with that interpretation, 1) From spec POV, only the most atomic (indivisible) elements of a payload are considered properties 2) DSP0266 clause about partial success does apply if at least one property was successfully changed, however.. 3) ..A device may reject the payload, entirely or partially, or apply properties at a less granular atomicity (complex objects) rather than individual properties properties. 4) A device ought to document what it applied and what didn't using appropriate annotations
|
|
|
Post by mraineri on Oct 4, 2024 19:17:11 GMT
On point 3, I don't quite agree completely. From a purely transactional perspective, if the payload is rejected, it's entirely rejected. It could be that only one property is wrong in the payload, but if a service rejects a payload and returns a 4XX or 5XX, the following semantics apply:
> If the service returns a client 4XX or service 5XX status code, the service encountered an error and the resource shall not have been modified or created as a result of the operation.
But you are correct about the "partial success" case; a service could have successfully applied a subset of the properties, and the service does have some flexibility in terms of how it can apply some but not all properties.
On point 4, the case for what was not applied is hardened in the spec as a "shall", so clients will always get this list back:
> In these cases, the service shall return the HTTP 200 OK status code and a resource representation with extended information that lists the properties that could not be updated.
|
|