Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24868 closed Bug (invalid)

Invalid kwarg passed to technical_500_response() handling SuspiciousOperation in debug mode

Reported by: andrewhayes1979 Owned by: nobody
Component: Core (URLs) Version: 1.8
Severity: Normal Keywords: technical_500_response suspiciousoperation
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Version: 1.8.2
File: django/core/handlers/base.py
Line: 206

...if in debug mode, and a suspicious operation is raised, the following code gets executed:

            if settings.DEBUG:
                return debug.technical_500_response(request, *sys.exc_info(), status_code=400)

...this causes the technical_500_response() function to throw a further exception because it's not expecting a "status_code" keyword argument.

Though I appreciate that SuspiciousOperation shouldn't really be thrown by user code (only by Django in production in relation to ALLOWED_HOSTS issues -- the code that uncovered this has since been modified), the error still needs addressing, whether in the code above, or amending in technical_debug_response() to accept status_code as a keyword argument.

Change History (3)

comment:1 by Baptiste Mispelon, 10 years ago

Hi,

Can you show an example of code that triggers the invalid kwarg error?

From what I can tell, technical_500_response does take a status_code argument: https://github.com/django/django/blob/stable/1.8.x/django/views/debug.py#L87

Thanks.

comment:2 by andrewhayes1979, 10 years ago

Resolution: invalid
Status: newclosed

comment:3 by andrewhayes1979, 10 years ago

This actually turned out to be an issue in django-extensions, something called null_technical_500_response()...needs patching there for Django 1.8+.

My bad.

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