WSOD when serializing a 404 response

Created on 6 April 2020, over 4 years ago
Updated 17 November 2023, about 1 year ago

The serialization of a 404 response fails because the generated content from the access denied exception cannot be serialized as a CSV.

TypeError: Argument 1 passed to League\Csv\Writer::insertOne() must be of the type array, string given, called in /mnt/files/local_mount/build/web/modules/contrib/csv_serialization/src/Encoder/CsvEncoder.php on line 158 in League\Csv\Writer->insertOne() (line 151 of /mnt/files/local_mount/build/vendor/league/csv/src/Writer.php) #0 /mnt/files/local_mount/build/web/modules/contrib/csv_serialization/src/Encoder/CsvEncoder.php(158): League\Csv\Writer->insertOne('') #1 /mnt/files/local_mount/build/vendor/symfony/serializer/Encoder/ChainEncoder.php(40): Drupal\csv_serialization\Encoder\CsvEncoder->encode(Array, 'csv', Array) #2 /mnt/files/local_mount/build/vendor/symfony/serializer/Serializer.php(276): Symfony\Component\Serializer\Encoder\ChainEncoder->encode(Array, 'csv', Array) #3 /mnt/files/local_mount/build/vendor/symfony/serializer/Serializer.php(119): Symfony\Component\Serializer\Serializer->encode(Array, 'csv', Array) #4 /mnt/files/local_mount/build/web/core/modules/serialization/src/EventSubscriber/DefaultExceptionSubscriber.php(77): Symfony\Component\Serializer\Serializer->serialize(Array, 'csv') #5 /mnt/files/local_mount/build/web/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php(112): Drupal\serialization\EventSubscriber\DefaultExceptionSubscriber->on4xx(Object(Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent)) #6 [internal function]: Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase->onException(Object(Symfony\Component

As I can see, the Serialization module has its own DefaultExceptionSubscriber that tries to return a result in the requested format, but it is unable to properly serialize response as CSV. My suggestion is adding a DefaultExceptionSubscriber to this module that properly handles the CSV serialization of 404 responses and any other exceptions.

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024