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.

Comments

mxr576 created an issue. See original summary.

mxr576’s picture

Screenshots from the callchain.

markdorison’s picture

Status: Active » Closed (outdated)

Please reopen with a merge request against 4.x if this issue is still relevant.