question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Elasticsearch support Normalization error

See original GitHub issue

Hi everyone, Thanks for this great work !

I’m using api-platform/core": "^2.4.0-beta.1", I followed Documentation to set up the Elasticsearch support and when I want to GET a collection with a DateTime attribute

/**
     * @var \DateTimeInterface
     *
     * @Gedmo\Timestampable(on="create")
     * @ORM\Column(name="created_at", type="datetime")
     * @Groups("timestampable_read")
     */
    private $createdAt;

I have the following issue : Cannot create an instance of DateTime from serialized data because its constructor requires parameter \"time\" to be present.

Stack trace

Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException:
Cannot create an instance of DateTime from serialized data because its constructor requires parameter "time" to be present.

  at vendor/symfony/serializer/Normalizer/AbstractNormalizer.php:428
  at Symfony\Component\Serializer\Normalizer\AbstractNormalizer->instantiateObject(array('2015-01-01T12:10:30Z'), 'DateTime', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'), object(ReflectionClass), false, 'elasticsearch')
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:157)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->instantiateObject(array('2015-01-01T12:10:30Z'), 'DateTime', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'), object(ReflectionClass), false, 'elasticsearch')
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:262)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize('2015-01-01T12:10:30Z', 'DateTime', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/api-platform/core/src/Bridge/Elasticsearch/Serializer/ItemNormalizer.php:64)
  at ApiPlatform\Core\Bridge\Elasticsearch\Serializer\ItemNormalizer->denormalize('2015-01-01T12:10:30Z', 'DateTime', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/symfony/serializer/Serializer.php:191)
  at Symfony\Component\Serializer\Serializer->denormalize('2015-01-01T12:10:30Z', 'DateTime', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:352)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->validateAndDenormalize('App\\User\\Entity\\User', 'createdAt', '2015-01-01T12:10:30Z', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
     (vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:277)
  at Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize(array('full_name' => 'Lucky', 'username' => 'jdoe', 'site' => '/sites/f45b3272-122a-4e29-a257-65c6d22829cd', 'plain_password' => 'Passw0rd!', 'admin' => false, 'sedentary_edenred_admin' => false, 'enabled' => true, 'roles' => array('ROLE_CE_LISTE_UPDATE', 'ROLE_ONGLET_PARAMETRES_AVANCES_UPDATE'), 'store' => '/stores/00000000-0000-0000-0000-000000000001', 'created_at' => '2015-01-01T12:10:30Z', 'uuid' => '0HjozWgBJzObu7ogPBVG'), 'App\\User\\Entity\\User', 'elasticsearch', array('allow_extra_attributes' => true, 'cache_key' => '601c065ecd9ab622c622bbc62f7e38dc'))
...

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
soyukacommented, Feb 12, 2019

This is definitely a bug, we’re in the process of fixing priority issues in https://github.com/api-platform/core/pull/2495

1reaction
ismail1432commented, Feb 12, 2019

To avoid the issue I had this in service.yaml with a priority higher than api_platform.elasticsearch.normalizer.item

  datetime_normalizer:
        class: Symfony\Component\Serializer\Normalizer\DateTimeNormalizer
        public: false
        tags:
            - { name: serializer.normalizer, priority: 9 }
Read more comments on GitHub >

github_iconTop Results From Across the Web

normalizer | Elasticsearch Guide [8.5] | Elastic
The normalizer is applied prior to indexing the keyword, as well as at search-time when the keyword field is searched via a query...
Read more >
Cannot normalize the point - not a number - Opster
A detailed guide on how to resolve errors related to "cannot normalize the point - not a number"
Read more >
Elasticsearch - How to normalize score when combining ...
Thirdly the problem they were trying to solve was quite different. Lastly I lack the source code that would help me to understand...
Read more >
Normalize data with Amazon Elasticsearch Service ingest ...
Your logstash source sends the data to an index with the name index-YYYY.MM.DD.HH (hours in the end). When you have an error in...
Read more >
Elastic Common Schema (ECS) Reference
The goal of ECS is to enable and encourage users of Elasticsearch to normalize their event data, so that they can better analyze,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found