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
On view that generates a PNG image, django-debug-toolbar alert panel crashes:
Traceback (most recent call last):
File "/home/nijel/weblate/weblate/.venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/home/nijel/weblate/weblate/.venv/lib/python3.11/site-packages/sentry_sdk/integrations/django/middleware.py", line 169, in __call__
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/home/nijel/weblate/weblate/.venv/lib/python3.11/site-packages/debug_toolbar/middleware.py", line 94, in __call__
panel.generate_stats(request, response)
File "/home/nijel/weblate/weblate/.venv/lib/python3.11/site-packages/debug_toolbar/panels/alerts.py", line 146, in generate_stats
html_content = response.content.decode(response.charset)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
The response is <HttpResponse status_code=200, "image/png"> and doesn't have charset set. In this case charset property falls back to the default, what happens to be 'utf-8'.
I think it should check response.headers["Content-Type"] if the response is something what makes sense to decode before doing so here:
On view that generates a PNG image, django-debug-toolbar alert panel crashes:
The response is
<HttpResponse status_code=200, "image/png">
and doesn't havecharset
set. In this case charset property falls back to the default, what happens to be 'utf-8'.I think it should check
response.headers["Content-Type"]
if the response is something what makes sense to decode before doing so here:https://github.com/jazzband/django-debug-toolbar/blob/9bcd6cac17fd1721d60c2b1b8218884caf0ee45e/debug_toolbar/panels/alerts.py#L145
The text was updated successfully, but these errors were encountered: