[Django] #24868: Invalid kwarg passed to technical_500_response() handling SuspiciousOperation in debug mode

11 views
Skip to first unread message

Django

unread,
May 28, 2015, 4:38:30 AM5/28/15
to django-...@googlegroups.com
#24868: Invalid kwarg passed to technical_500_response() handling
SuspiciousOperation in debug mode
-------------------------+-------------------------------------------------
Reporter: | Owner: nobody
andrewhayes1979 |
Type: Bug | Status: new
Component: Core | Version: 1.8
(URLs) | Keywords: technical_500_response
Severity: Normal | suspiciousoperation
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 1 | UI/UX: 0
-------------------------+-------------------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24868>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 28, 2015, 4:43:24 AM5/28/15
to django-...@googlegroups.com
#24868: Invalid kwarg passed to technical_500_response() handling
SuspiciousOperation in debug mode
-------------------------------------+-------------------------------------
Reporter: andrewhayes1979 | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
technical_500_response | Unreviewed
suspiciousoperation |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by bmispelon):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24868#comment:1>

Django

unread,
May 28, 2015, 4:51:27 AM5/28/15
to django-...@googlegroups.com
#24868: Invalid kwarg passed to technical_500_response() handling
SuspiciousOperation in debug mode
-------------------------------------+-------------------------------------
Reporter: andrewhayes1979 | Owner: nobody
Type: Bug | Status: closed

Component: Core (URLs) | Version: 1.8
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
technical_500_response | Unreviewed
suspiciousoperation |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by andrewhayes1979):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/24868#comment:2>

Django

unread,
May 28, 2015, 4:53:26 AM5/28/15
to django-...@googlegroups.com
#24868: Invalid kwarg passed to technical_500_response() handling
SuspiciousOperation in debug mode
-------------------------------------+-------------------------------------
Reporter: andrewhayes1979 | Owner: nobody
Type: Bug | Status: closed
Component: Core (URLs) | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
technical_500_response | Unreviewed
suspiciousoperation |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by andrewhayes1979):

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24868#comment:3>

Reply all
Reply to author
Forward
0 new messages