Core: UnexpectedValueException on bad DateTime value

Created on 6 Oct 2016  路  6Comments  路  Source: api-platform/core

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)

bug

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.

All 6 comments

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 ;).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bendavies picture bendavies  路  3Comments

DenisVorobyov picture DenisVorobyov  路  3Comments

gustawdaniel picture gustawdaniel  路  3Comments

theshaunwalker picture theshaunwalker  路  3Comments

stipic picture stipic  路  3Comments