You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SerializerErrorRenderer class cannot extract a csv acceptable header from a request. The static method SerializerErrorRenderer::getPreferredFormat delegates that work to the Request->getPreferredFormat method which is unable to return "csv" because static::$formats doesn't contain information about "csv" format (in the case when request attribute "_format" is not set explicitly).
I can't remember, but there was a side effect somewhere after appending a "csv" key-value pair to $formats. I need to review my code again and try to remember/find out what was wrong.
Symfony version(s) affected
6.2.10
Description
The SerializerErrorRenderer class cannot extract a csv acceptable header from a request. The static method SerializerErrorRenderer::getPreferredFormat delegates that work to the Request->getPreferredFormat method which is unable to return "csv" because static::$formats doesn't contain information about "csv" format (in the case when request attribute "_format" is not set explicitly).
How to reproduce
Create a controller that throws any exception.
Run a cURL request including the "Accept: text/csv" header.
curl -X GET -i --header 'Accept: text/csv' http://localhost:8000/exception
Expected result:
Actual result:
Possible Solution
Add a
'csv' => ['text/csv', 'application/csv', 'text/x-comma-separated-values', 'text/x-csv'],
line into initializeFormats method of Request class.Additional Context
Everything works fine when the format is explicitly set in a preview mode i.e.
curl -X GET -i --header 'Accept: text/csv' http://localhost:8000/_error/500.csv
The request attribute "_format" is set to "csv" in this case.
The text was updated successfully, but these errors were encountered: