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
I get a 400 Bad Request, as expected
(message: "DateTimeImmutable::__construct(): Failed to parse time string (foo) at position 0 (f): The timezone could not be found in the database")
The text was updated successfully, but these errors were encountered:
@soyuka: I don't think so (this has nothing to do with "short UUID"). Rather #3045 (but that was for e.g. GET /foos/foo) and #3473 (but that was for ramsey/uuid ^4.0).
By the way, this issue also exists when using the $uuid as the id, i.e. annotating it with @ApiProperty(identifier=true)
API Platform version(s) affected: 2.6.3, 2.6.4
ramsey/uuid
3.9.3Description
(see title) when using the
UuidInterface
type declaration for automatic denormalizationHow to reproduce
On PHP 7.4
Request:
POST /foos
with body (Content-Type: application/ld+json):Expected: 400 Bad Request
Actual: 500 Internal Server Error
(message: "Invalid UUID string: foo")
Possible Solution
In
ApiPlatform\Core\Bridge\RamseyUuid\Serializer\UuidDenormalizer
, wrapreturn Uuid::fromString($data);
with a try-catch (like inApiPlatform\Core\Bridge\RamseyUuid\Identifier\Normalizer\UuidNormalizer
) and convert theRamsey\Uuid\Exception\InvalidUuidStringException
to an appropriate exception (a subclass ofSymfony\Component\Serializer\Exception\ExceptionInterface
)?Additional Context
For this body:
I get a 400 Bad Request, as expected
(message: "DateTimeImmutable::__construct(): Failed to parse time string (foo) at position 0 (f): The timezone could not be found in the database")
The text was updated successfully, but these errors were encountered: