Core: Error message for invalid UUID on the URL

Created on 4 Sep 2019  路  8Comments  路  Source: api-platform/core

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.

enhancement question

All 8 comments

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.

Great. It's ok if I work on it?

Please go ahead. PR welcome!

we fixed this in #3132 afaik

Was this page helpful?
0 / 5 - 0 ratings