Opened 14 years ago

Closed 14 years ago

#13090 closed (fixed)

Incorrect handling of middleware exceptions

Reported by: Andrey Golovizin Owned by: Ivan Sagalaev
Component: HTTP handling Version: dev
Severity: Keywords:
Cc: Andrey Golovizin Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django won't display a 500 error page with DEBUG=False if an exception is raised from a middleware. The following traceback is returned instead:

Traceback (most recent call last):

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/handlers/wsgi.py", line 241, in __call__
    response = self.get_response(request)

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/handlers/base.py", line 143, in get_response
    return self.handle_uncaught_exception(request, resolver, exc_info)

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/handlers/base.py", line 178, in handle_uncaught_exception
    callback, param_dict = resolver.resolve500()

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/urlresolvers.py", line 268, in resolve500
    return self._resolve_special('500')

  File "/home/erosennin/workspace/ipi/django/trunk/django/core/urlresolvers.py", line 258, in _resolve_special
    callback = getattr(self.urlconf_module, 'handler%s' % view_type)

AttributeError: 'NoneType' object has no attribute 'handler500'

This problem has been fixed in [12165], then reintroduced in [12186].

See also #6094.

Attachments (2)

13090.diff (1.8 KB ) - added by Ivan Sagalaev 14 years ago.
Patch
13090.1.diff (3.7 KB ) - added by Ivan Sagalaev 14 years ago.
Patch with tests

Download all attachments as: .zip

Change History (6)

comment:1 by Ivan Sagalaev, 14 years ago

Owner: changed from nobody to Ivan Sagalaev

Huh... We've found the same bug just yesterday. I'll try to fix this tomorrow since both commits is my code.

comment:2 by Ivan Sagalaev, 14 years ago

P.S. EroSennin, and the separate bug report with a traceback is indeed helpful.

by Ivan Sagalaev, 14 years ago

Attachment: 13090.diff added

Patch

comment:3 by Ivan Sagalaev, 14 years ago

Has patch: set

Attached patch fixes the issue in what I believe a clean way. There's no test since the bug only occurs under DEBUG=False and AFAIK tests always run under DEBUG=True.

by Ivan Sagalaev, 14 years ago

Attachment: 13090.1.diff added

Patch with tests

comment:4 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [12773]) Fixed #13090 -- Corrected handling of errors in middleware when DEBUG=False. Thanks to EroSennin for the report, and Ivan Sagalaev for the patch.

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