Fix to defer resolution of ContentID in Uri - #481
Conversation
|
Do you have an added test that validates that the correct URL is executed (with $1 replaced by the locationheader returned by the request with id = 1)? When I tried a similar fix I got back a 404 for the second request because $1/TestBs/$ref was invalid (the $1 was never resolved). |
@mikepizzo I applied the fix to the project I used to repro the issue and it works perfectly. Here's the batch payload I'm basing the test on and the CreateRef controller action is being hit. The |
|
Okay; I see the disconnect. This does fix the absolute Uri issue, but there is a related issue that also needs to be addressed, which is that $ids can reference any request, not just in the same changeset (that was an old restriction that has been relaxed). So, for example, the repro in #360 would still not work, because the two requests are not grouped together in an atomicityGroup. I have a fix for that, as well as the relative URL issue that this fixes, which I'll share in a draft PR and we can discuss... |
|
|
See #482 for an alternate approach.
|
@mikepizzo I see a potential problem here. Here is the scenario: If all the requests are in the same batch and you append base Uri at the point you're doing it, before we have resolved the location for resource A (that corresponds to |
|
#481 (comment) |
|
Addressed in #482 |
Fixes #365
This PR fixes the issue by deferring resolution of ContentID in Uri (e.g.
$1/TestBs/$ref) to much later when the dependent operations have already been executed and the ContentID mapped to a location for a resource. That will be done here:AspNetCoreOData/src/Microsoft.AspNetCore.OData/Batch/ODataBatchRequestItem.cs
Lines 44 to 56 in 69eec03
CopyAbsoluteUrl(Uri)is called and the request Url has been resolved