On an entity DateTime nullable field (with column type="datetime"), sending an invalid datetime (like "invalid-date") in PUT or POST throws an UnexpectedValueException with error code 500.
Assert is not triggered, and I think the error code should be 400.
(the exception is thrown in file SymfonyComponentSerializerNormalizerDateTimeNormalizer line 74)
It is intended that assertions are not triggered (type checking is done before the validation), but indeed this exception should be converted to a 400 HTTP error.
@gpenverne, which version of API Platform do you use?
In the ^2.0@rc, Symfony\Component\Serializer\Exception\UnexpectedValueException implements Symfony\Component\Serializer\Exception\ExceptionInterface which is caught by API Platform to return a 400 HTTP error.
But this seems different with 1.x.
@meyerbaptiste We are using v2.0.0-beta.3
I just tested with v2.0.0-beta.3 and I really can't reproduce this issue! Can you provide a small public project to reproduce it?
@gpenverne Is it still a bug ? Could you please provide something to reproduce ?
If you still have the issue please mentions me with a little exemple if you can ;).
Most helpful comment
It is intended that assertions are not triggered (type checking is done before the validation), but indeed this exception should be converted to a 400 HTTP error.