Opened 14 years ago

Closed 13 years ago

#14506 closed Bug (fixed)

Crash on HEAD request

Reported by: azurit Owned by: nobody
Component: Documentation Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Alex Gaynor)

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 94, in get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)

  File "/usr/lib/python2.5/site-packages/django/middleware/doc.py", line 15, in process_view
    if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or (request.user.is_authenticated() and request.user.is_staff)):

AttributeError: 'WSGIRequest' object has no attribute 'user'

Attachments (2)

patch (806 bytes ) - added by Klaas van Schelven 14 years ago.
Assert the right middleware is running similar to contrib.auth.middleware
docs (529 bytes ) - added by Klaas van Schelven 14 years ago.
Added dependency description to the docs (I'm not too sure on the format, so please test first)

Download all attachments as: .zip

Change History (14)

comment:1 by Alex Gaynor, 14 years ago

Description: modified (diff)

Reformatted, please use the preview button in the future.

comment:2 by pandres, 14 years ago

Resolution: invalid
Status: newclosed

Please give us more information on how to reproduce. Also try a newer django version.

comment:3 by Jannis Leidel, 14 years ago

Looks like request.user is not set. Which means the Auth middleware was not successfully run.

in reply to:  3 ; comment:4 by azurit, 14 years ago

Replying to jezdez:

Looks like request.user is not set. Which means the Auth middleware was not successfully run.


Yes, Auth middleware is NOT loaded.

comment:5 by azurit, 14 years ago

Resolution: invalid
Status: closedreopened

in reply to:  4 ; comment:6 by Karen Tracey, 14 years ago

Replying to azurit:

Replying to jezdez:

Looks like request.user is not set. Which means the Auth middleware was not successfully run.


Yes, Auth middleware is NOT loaded.

If you don't have the auth middleware loaded, why do you have the XView middleware loaded (that's the code that is generating the exception)? That middleware is documented (http://docs.djangoproject.com/en/dev/ref/middleware/#django.middleware.doc.django.middleware.doc.XViewMiddleware) as providing some function for the admindocs feature, which is only accessible from admin, which requires the auth middleware to be in place. So XView assumes auth middleware is loaded.

Leaving open since I guess the XView code could handle this more gracefully, but the easiest fix would seem to be for you to remove it from your middleware setting.

in reply to:  6 comment:7 by azurit, 14 years ago

Replying to kmtracey:

Replying to azurit:

Replying to jezdez:

Looks like request.user is not set. Which means the Auth middleware was not successfully run.


Yes, Auth middleware is NOT loaded.

If you don't have the auth middleware loaded, why do you have the XView middleware loaded (that's the code that is generating the exception)? That middleware is documented (http://docs.djangoproject.com/en/dev/ref/middleware/#django.middleware.doc.django.middleware.doc.XViewMiddleware) as providing some function for the admindocs feature, which is only accessible from admin, which requires the auth middleware to be in place. So XView assumes auth middleware is loaded.

Leaving open since I guess the XView code could handle this more gracefully, but the easiest fix would seem to be for you to remove it from your middleware setting.


Thank you, i removed XView middleware. Maybe documentation should mention that XView depends on Auth ?

comment:8 by Gabriel Hurley, 14 years ago

Triage Stage: UnreviewedAccepted

by Klaas van Schelven, 14 years ago

Attachment: patch added

Assert the right middleware is running similar to contrib.auth.middleware

by Klaas van Schelven, 14 years ago

Attachment: docs added

Added dependency description to the docs (I'm not too sure on the format, so please test first)

comment:9 by Julien Phalip, 13 years ago

Severity: Normal
Type: Bug

comment:10 by Thejaswi Puthraya, 13 years ago

Component: UncategorizedDocumentation
Easy pickings: unset
UI/UX: unset

comment:11 by Horst Gutmann <zerok@…>, 13 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

Patch still applies cleanly to trunk.

comment:12 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: reopenedclosed

In [16496]:

Fixed #14506 -- Added an assertion to XViewMiddleware about the dependency on the authentication middleware. Thanks, vanschelven.

Note: See TracTickets for help on using tickets.
Back to Top