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
click "export csv" of a chart in dashboard page, request /superset/explore_json/?form_data=%7B%22slice_id%22%3A16%7D&csv=true, got an error message:
[ERROR] Error handling request /superset/explore_json/?form_data=%7B%22slice_id%22%3A18%7D&csv
=true
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/gunicorn/workers/sync.py", line 135, in handle
self.handle_request(listener, req, client, addr)
File "/usr/local/lib/python3.5/dist-packages/gunicorn/workers/sync.py", line 182, in handle_request
resp.write(item)
File "/usr/local/lib/python3.5/dist-packages/gunicorn/http/wsgi.py", line 333, in write
self.send_headers()
File "/usr/local/lib/python3.5/dist-packages/gunicorn/http/wsgi.py", line 329, in send_headers
util.write(self.sock, util.to_bytestring(header_str, "ascii"))
File "/usr/local/lib/python3.5/dist-packages/gunicorn/util.py", line 507, in to_bytestring
return value.encode(encoding)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 253-255: ordinal not in range(128)
notice the strange characters  in the value of Set-Cookie header, they are b'\xef\xbb\xbf' in hex, aka UTF-8 BOM, they are the culprit of this exception.
IMHO superset should encode csv data by itself, simplely return encoded binary response, do not rely on Response.charset, which has side effect that will mess up with 8 bits http header value.
with #5377 and #5372, I think superset is still at an early stage in supporting Python3 and non-English language environment, especially on CSV exporting, this feature needs a comprehensive refactor.
as a python3 and Chinese user, I would like to contribute some time to it, but I want to hear thoughts from maintainers and the community first.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.
This is mainly because the cause of the Chinese code, if you are in the download CSV file these mistakes, you can modify the superset of the source code: “site-packages/superset/views/core.py” f"attachment: filename={query.name}.csv" Modified to attachment: filename=%s.csv" % (quote(query.name))
Superset version
Superset 0.26.3
Python 3.5.3 (via docker)
Steps to reproduce
set config:
click "export csv" of a chart in dashboard page, request
/superset/explore_json/?form_data=%7B%22slice_id%22%3A16%7D&csv=true
, got an error message:Root Cause:
dumped headers data result in the exception:
notice the strange characters

in the value ofSet-Cookie
header, they areb'\xef\xbb\xbf'
in hex, aka UTF-8 BOM, they are the culprit of this exception.flask/werkzeug will encode header value with
Response.charset
, superset has ovrridden charset with the value ofCSV_EXPORT.encoding
, in PR #3484, but csv encoding is not always http header safe, likeutf-8-sig
, adds extra BOM bytes that gunicorn dont understand.related with #5372.
IMHO superset should encode csv data by itself, simplely return encoded binary response, do not rely on
Response.charset
, which has side effect that will mess up with 8 bits http header value.The text was updated successfully, but these errors were encountered: