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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | screeshot-2020-04-06-08-40-21.png | 126.21 KB | mxr576 |
| #2 | screeshot-2020-04-06-08-36-22.png | 182.8 KB | mxr576 |
Comments
Comment #2
mxr576Screenshots from the callchain.
Comment #3
markdorisonPlease reopen with a merge request against 4.x if this issue is still relevant.