API Platform version(s) affected: 3.1.12
Description
Upgraded API Platform from 3.1.9 to 3.1.12.
The issue I am experiencing is that when doing PATCH/PUT request and providing in that request a field which is a relation with IRI value, the value does not get resolved properly.
Basically what happens is the following:
- Item provider loads for the PATCH/PUT request the resource I am trying to update
- Next it calls again the Item Provider for all the fields with IRI value in the PATCH payload
- This happens here: vendor/api-platform/core/src/Symfony/Routing/IriConverter.php:95
if ($item = $this->provider->provide($operation, $uriVariables, $context)) {
return $item;
}
throw new ItemNotFoundException(sprintf('Item not found for "%s".', $iri));
- The problem is that it doesn't pass the correct ID, instead of the embedded resource ID the ID which is passed to the provider is the initial id of the PUT object, so the above code will always throw an exception.
How to reproduce
- Create two resources, for example Alpha and Beta
- Create a field in Beta which is a relation to Alpha
- Try to create/update Beta
PATCH /betas/{id}
{
"alpha": "/alphas/{id}"
}
It will throw 400 error. And it basically throws ItemNotFoundException due to wrong identifier being passed to state provider.
API Platform version(s) affected: 3.1.12
Description
Upgraded API Platform from 3.1.9 to 3.1.12.
The issue I am experiencing is that when doing PATCH/PUT request and providing in that request a field which is a relation with IRI value, the value does not get resolved properly.
Basically what happens is the following:
How to reproduce
It will throw 400 error. And it basically throws ItemNotFoundException due to wrong identifier being passed to state provider.