Hi.
Having an API Resource with the following identifier configuration (I got it from the demo), when I send a request like this: curl -X GET "https://demo.api-platform.com/books/wrong-id" -H "accept: application/ld+json" It fails because of the denormalization, returning a 404 error thrown by the ReadListener
/**
* @var UuidInterface
*
* @ORM\Column(type="uuid", unique=true)
* @ORM\Id
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator")
*/
private $id;
So, the error handling works perfectly. But, the message response of the request is: "Not found, because of an invalid identifier configuration". My question: What is the best approach to customize this message? It isn't a configuration mismatch on that case.
The exception message is indeed misleading. We'll have to see if we can tell the different cases apart, but in this case it should say something like: "Not found, because of an invalid identifier format"
WDYT?
Oh. I just realized I opened this with the wrong user.
Anyway. I agree. We could throw a different exception type from the ApiPlatform\Core\Bridge\RamseyUuid\Identifier\Normalizer\UuidNormalizer::denormalize when the parse failed.
This should be the correct exception: https://github.com/symfony/symfony/blob/v4.3.4/src/Symfony/Component/Serializer/Exception/NotNormalizableValueException.php
Great. It's ok if I work on it?
Please go ahead. PR welcome!
we fixed this in #3132 afaik