DebuggingLoggerMiddleware crashes with "AttributeError: 'WSGIRequest' object has no attribute 'content'"

Bug #1227543 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:
ERROR 2013-09-19 09:31:39,519 django.request Internal Server Error: /MAAS/api/1.0/files/provider-state/
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 92, in get_response
    response = middleware_method(request)
  File "/usr/lib/python2.7/dist-packages/maasserver/middleware.py", line 223, in process_request
    logger.info("%s\n%r\n%s", header, request, request.content)
AttributeError: 'WSGIRequest' object has no attribute 'content'

Tags: log

Related branches

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

We should use request.GET and request.POST instead (see https://github.com/django/django/blob/master/django/core/handlers/wsgi.py).

Revision history for this message
Gavin Panella (allenap) wrote :

I assume request.content had headers and such, unmolested. The (misnamed) request.GET and request.POST properties are processed (though that's useful too) but we'd need to include request.META to get headers too, I think.

I've also noticed the django.http.request.build_request_repr() function which:

    """
    Builds and returns the request's representation string. The request's
    attributes may be overridden by pre-processed values.
    """

Let's allow Django to unravel its spaghetti interiors for us?

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

> I've also noticed the django.http.request.build_request_repr() function which:

That sounds like exactly what we're looking for.

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.