Code

Opened 4 years ago

Closed 3 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)

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 vanschelven 3 years ago.
Assert the right middleware is running similar to contrib.auth.middleware
docs (529 bytes) - added by vanschelven 3 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 Changed 4 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Reformatted, please use the preview button in the future.

comment:2 Changed 4 years ago by pandres

  • Resolution set to invalid
  • Status changed from new to closed

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

comment:3 follow-up: Changed 4 years ago by jezdez

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

comment:4 in reply to: ↑ 3 ; follow-up: Changed 4 years ago by 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.

comment:5 Changed 4 years ago by azurit

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:6 in reply to: ↑ 4 ; follow-up: Changed 4 years ago by 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.

comment:7 in reply to: ↑ 6 Changed 4 years ago by azurit

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 Changed 4 years ago by gabrielhurley

  • Triage Stage changed from Unreviewed to Accepted

Changed 3 years ago by vanschelven

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

Changed 3 years ago by vanschelven

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

comment:9 Changed 3 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:10 Changed 3 years ago by thejaswi_puthraya

  • Component changed from Uncategorized to Documentation
  • Easy pickings unset
  • UI/UX unset

comment:11 Changed 3 years ago by Horst Gutmann <zerok@…>

  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

Patch still applies cleanly to trunk.

comment:12 Changed 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from reopened to closed

In [16496]:

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.