api-platform / api-platform/core
Profiler error when deserializing when using UUID
- Langage dominant
- PHP
- Étoiles
- 2.6k
- Forks
- 980
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 49
Description
**Symfony version(s) affected**: 5.2.* - 5.3.* (tested on 5.2.10 and 5.3.1)
**Description**
When an entity uses UUID as its ID type and an insertion to database error occurs the profiler stops working, shows exception 500 error and it cannot deserialize the exception, because of which the API Platform cannot return hydra:Error message.
Due to the error: `Due to the error: API Platform cannot handle the error. This is due to the use of UUID which is stored in the database as binary` API Platform cannot handle the error. This is due to the use of UUID which is stored in the database as binary
**How to reproduce**
1. Create an entity class with UUID being used as its ID type
2. Add new required field
3. Create new entity object
4. Persist object without required field.
**Additional context**
Demo code:
https://github.com/kskrzypkowski/symfony-uuid-issue
Issue reference
https://github.com/symfony/symfony/issues/41620
Here is a youtube video that shows the whole error, tested on the repository to which the link is above.
https://youtu.be/iDKKqu1QLTs
Stacktrace
```
Symfony\Component\Serializer\Exception\NotEncodableValueException:
Malformed UTF-8 characters, possibly incorrectly encoded
at /var/www/api/vendor/symfony/serializer/Encoder/JsonEncode.php:54
at Symfony\Component\Serializer\Encoder\JsonEncode->encode(array('@context' => '/api/contexts/Error', '@type' => 'hydra:Error', 'hydra:title' => 'An error occurred', 'hydra:description' => 'Malformed UTF-8 characters, possibly incorrectly encoded', 'trace' => array(array('namespace' => '', 'short_class' => '', 'class' => '', 'type' => '', 'function' => '', 'file' => '/var/www/api/vendor/symfony/serializer/Encoder/JsonEncode.php', 'line' => 54, 'args' => array()), array('namespace' => 'Symfony\\Component\\Serializer\\Encoder', 'short_class' => 'JsonEncode', 'class' => 'Symfony\\Component\\Serializer\\Encoder\\JsonEncode', 'type' => '->', 'function' => 'encode', 'file' => '/var/www/api/vendor/symfony/serializer/Encoder/JsonEncoder.php', 'line' => 37, 'args' => array(array('array', array('@context' => array('string', '/api/contexts/Error'), '@type' => array('string', 'hydra:Error'), 'hydra:title' => array('string', 'An error occurred'), 'hydra:description' => array('string', 'An exception occurred while executing \'INSERT INTO tcp1_file_service (id, order_number, status, regular_price, total_price, discount, token_type, tuning_target, vehicle_year, vehicle_hp, vehicle_kw, vehicle_fuel_octane_rating, vehicle_license_plate, vehicle_vin, vehicle_hardware_number, vehicle_software_number, on_dyno, additional_email, additional_comment, engineer_remarks, created_at, updated_at, closed_at, custom_vehicle_data, client_id, assigned_worker_id, vehicle_brand_id, vehicle_model_id, vehicle_model_generation_id, vehicle_engine_id, vehicle_ecu_id, vehicle_tcu_id, vehicle_gearbox_id, read_method_id, tuning_type_id, time_frame_id, client_site_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\' with params ["\\xab\\x45\\x1d\\x14\\xdf\\x2a\\x4f\\x50\\x9a\\xa0\\x3c\\x6b\\x9b\\xbd\\x83\\xf0", "TC-21-00007", 1, 0, 0, 0, null, null, "2020", 256, 200, 95, "WPR 3996G", "", "", "", 1, "", "", null, "2021-06-08 16:12:09", "2021-06-08 16:12:09", null, "[]", 1, null, 1, 1, 1, 1, 1, 1, 1, 1, null, 1, 1]:SQLSTATE[23000]: Integrity constraint violation: 1048 Column \'token_type\' cannot be null'), 'trace' => array('array', array(array('array', array('namespace' => array('string', ''), 'short_class' => array('string', ''), 'class' => array('string', ''), 'type' => array('string', ''), 'function' => array('string', ''), 'file' => array('string', '/var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php'), 'line' => array('integer', 125), 'args' => array('array', array(*DEEP NESTED ARRAY*)))), array('array', array('namespace' => array('string', 'Doctrine\\DBAL\\Driver'), 'short_class' => array('string', 'AbstractMySQLDriver'), 'class' => array('string', 'Doctrine\\DBAL\\Driver\\AbstractMySQLDriver'), 'type' => array('string', '->'), 'function' => array('string', 'convertException'), 'file' => array('string', '/var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php'), 'line' => array('integer', 182), 'args' => array('array', array(*DEEP NESTED ARRAY*)))), array('array', array('namespace' => array('string', 'Doctrine\\DBAL'), 'short_class' => array('string', 'DBALException'), 'class' => array('string', 'Doctrine\\DBAL\\DBALException'), 'type' => array('string', '::'), 'function' => array('string', 'wrapException'), 'file' => array('string', '/var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php'), 'line' => array('integer', 159), 'args' => array('array', array(*DEEP NESTED ARRAY*)))), array('array', array('namespace' => array('string', 'Doctrine\\DBAL'), 'short_class' => array('string', 'DBALException'), 'class' => array('string', 'Doctrine\\DBAL\\DBALException'), 'type' => array('string', '::'), 'function' => array('string', 'driverExceptionDuringQuery'), 'file' => array('string', '/var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php'), 'line' => array('integer', 2214), 'args' => array('array', array(*DEEP NESTED ARRAY*)))), array('array', array('namespace' => array('string', 'Doctrine\\DBAL'), 'short_class' => array('string', 'Connection'), 'class' => array('string', 'Doctrine\\DBAL\\Connection'), 'type' => array('string', '->'), 'function' => array('string', 'handleExceptionDuringQuery'), 'file' => array('string', '/var/www/api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php'), 'line' => array('integer', 183), 'args' => array('array', array(*DEEP NESTED ARRAY*)))), array('array', array('namespace' => array('string', 'Doctrine\\DBAL'), 'short_class' => array('string', 'Statement'), 'class' =>
[...]
```


Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.