DebuggingLoggerMiddleware crashes with "UnicodeDecodeError"

Bug #1227558 reported by Raphaël Badin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Raphaël Badin

Bug Description

I enabled the DebuggingLoggerMiddleware on the daily package (1.4+bzr1589+dfsg-0+1623+200~ppa0~ubuntu13.10.1) and it crashed with (in apache2/error/log):

[Thu Sep 19 10:00:16.470053 2013] [:error] [pid 2467:tid 140661317871360] Logged from file middleware.py, line 231
[Thu Sep 19 10:00:16.899208 2013] [:error] [pid 2467:tid 140661317871360] Traceback (most recent call last):
[Thu Sep 19 10:00:16.899581 2013] [:error] [pid 2467:tid 140661317871360] File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
[Thu Sep 19 10:00:16.899919 2013] [:error] [pid 2467:tid 140661317871360] msg = self.format(record)
[Thu Sep 19 10:00:16.900164 2013] [:error] [pid 2467:tid 140661317871360] File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
[Thu Sep 19 10:00:16.900471 2013] [:error] [pid 2467:tid 140661317871360] return fmt.format(record)
[Thu Sep 19 10:00:16.900738 2013] [:error] [pid 2467:tid 140661317871360] File "/usr/lib/python2.7/logging/__init__.py", line 464, in format
[Thu Sep 19 10:00:16.901040 2013] [:error] [pid 2467:tid 140661317871360] record.message = record.getMessage()
[Thu Sep 19 10:00:16.901313 2013] [:error] [pid 2467:tid 140661317871360] File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage
[Thu Sep 19 10:00:16.901618 2013] [:error] [pid 2467:tid 140661317871360] msg = msg % self.args
[Thu Sep 19 10:00:16.901904 2013] [:error] [pid 2467:tid 140661317871360] UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)

Tags: log

Related branches

Revision history for this message
Raphaël Badin (rvb) wrote :

DebuggingLoggerMiddleware.process_response() should probably encode the unicode strings it manipulates instead of just implicitly converting them to strings.

Revision history for this message
Raphaël Badin (rvb) wrote :

We might want to use HttpResponse.serialize here. The docstring for the method says:
"""Full HTTP message, including headers, as a bytestring."""

(see https://github.com/django/django/blob/master/django/http/response.py)

Raphaël Badin (rvb)
Changed in maas:
milestone: none → 13.10
assignee: nobody → Raphaël Badin (rvb)
status: Triaged → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.