You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
atomicityGroup as a dependsOn value fails for Odata v4 requests, but succeeds in Odata v4.01 requests.
In Json batch, we use atomicGroup Id in dependsOn for 2 reasons:
To extract Request ids for use in reference Uris (in v4.01).
Sequence requests so that they are executed in a certain order (in both v4 and v4.01).
The current implementation of dependsOn atomicityGroup is aimed at extracting request Ids for use in reference uris.
This works well in Odata v4.01 but not in Odata v4. This is because in Odata v4, the last request Id in a group is not added to the contentId cache,hence validation fails in the snippets below.
System.AggregateException: One or more errors occurred. (One or more errors occurred. (The dependsOn Id: [3] in request [4] is not matching any of the request Id and atomic group Id seen so far. Forward reference is not allowed.))
---> System.AggregateException: One or more errors occurred. (The dependsOn Id: [3] in request [4] is not matching any of the request Id and atomic group Id seen so far. Forward reference is not allowed.)
---> Microsoft.OData.ODataException: The dependsOn Id: [3] in request [4] is not matching any of the request Id and atomic group Id seen so far. Forward reference is not allowed.
at Microsoft.OData.ODataBatchReader.BuildOperationRequestMessage(Func`1 streamCreatorFunc, String method, Uri requestUri, ODataBatchOperationHeaders headers, String contentId, String groupId, IEnumerable`1 dependsOnRequestIds, Boolean dependsOnIdsValidationRequired)
at Microsoft.OData.JsonLight.ODataJsonLightBatchReader.CreateOperationRequestMessageImplementation()
at Microsoft.OData.TaskUtils.GetTaskForSynchronousOperation[T](Func`1 synchronousOperation)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at Microsoft.AspNet.OData.Batch.ODataBatchReaderExtensions.ReadOperationInternalAsync(ODataBatchReader reader, HttpContext originalContext, Guid batchId, Nullable`1 changeSetId, CancellationToken cancellationToken, Boolean bufferContentStream)
at Microsoft.AspNet.OData.Batch.ODataBatchReaderExtensions.ReadChangeSetRequestAsync(ODataBatchReader reader, HttpContext context, Guid batchId, CancellationToken cancellationToken)
at Microsoft.AspNet.OData.Batch.DefaultODataBatchHandler.ParseBatchRequestsAsync(HttpContext context)
at Microsoft.AspNet.OData.Batch.DefaultODataBatchHandler.ProcessBatchAsync(HttpContext context, RequestDelegate nextHandler)
at Microsoft.AspNet.OData.Batch.ODataBatchMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Additional detail
From the protocol, The value of dependsOn is an array of strings whose values MUST be values of either id or atomicityGroup of preceding request objects; forward references are not allowed. If a request depends on another request that is part of a different atomicity group, the atomicity group MUST be listed in dependsOn. https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_BatchRequest
KenitoInc
changed the title
Enable atomicityGroup as a dependsOn value in Odata BatchReader and BatchWriter
Fix bug on atomicityGroup as a dependsOn value in Odata v4
Jul 2, 2020
atomicityGroup
as adependsOn
value fails forOdata v4
requests, but succeeds inOdata v4.01
requests.In Json batch, we use atomicGroup Id in dependsOn for 2 reasons:
The current implementation of dependsOn atomicityGroup is aimed at extracting request Ids for use in reference uris.
This works well in Odata v4.01 but not in Odata v4. This is because in Odata v4, the last request Id in a group is not added to the contentId cache,hence validation fails in the snippets below.
odata.net/src/Microsoft.OData.Core/Batch/ODataBatchWriter.cs
Lines 518 to 528 in d6cebf5
odata.net/src/Microsoft.OData.Core/Batch/ODataBatchReader.cs
Lines 319 to 328 in f375e46
The validations above should not be applicable to v4 since we may want to use atomicity groups to sequence requests without using reference Uris.
Assemblies affected
Microsoft.OData.Core v7.6.4
Reproduce steps
Using postman, make a batch request to an odata service with a payload similar to the one below
POST http://localhost:6143/odata/$batch
Expected result
Batch request executed successfully.
Actual result
Error 500
Additional detail
From the protocol, The value of dependsOn is an array of strings whose values MUST be values of either id or atomicityGroup of preceding request objects; forward references are not allowed. If a request depends on another request that is part of a different atomicity group, the atomicity group MUST be listed in dependsOn.
https://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_BatchRequest
Referencing across changesets was introduced in Odata v4.01 https://docs.oasis-open.org/odata/new-in-odata/v4.01/cn04/new-in-odata-v4.01-cn04.html#_Toc21700029
The text was updated successfully, but these errors were encountered: