[Django] #27191: Generation of error reports fails if request.GET, POST, FILES or COOKIES contains key 'items'

13 views
Skip to first unread message

Django

unread,
Sep 7, 2016, 6:08:41 AM9/7/16
to django-...@googlegroups.com
#27191: Generation of error reports fails if request.GET, POST, FILES or COOKIES
contains key 'items'
-------------------------------+--------------------
Reporter: anatolyrr | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
When `DEBUG` is True, if the `request.GET` or another QueryDict contains
key named `'items'` and a view raises an exception, the generation of
error report fails. Due to a difference in
`django.views.debug.TECHNICAL_500_TEMPLATE` and
`TECHNICAL_500_TEXT_TEMPLATE`, the actual behaviour varies.

==== Normal requests ====

For normal requests the output ''is'' produced, but the query variables
are dumped in a wrong way. For example, for request 'GET
/test/?items=Oops' the dump will contain a table:

** GET **
|| Variable || Value ||
|| O || `''` ||
|| o || `''` ||
|| p || `''` ||
|| s || `''` ||

This is because `TECHNICAL_500_TEMPLATE` iterates QueryDict this way:

{{{
{% for var in filtered_POST.items %} ... {{ var.0 }} ... {{ var.1 }} ...
}}}


==== Ajax requests ====

For ajax requests the plain text error report generation itself raises an
exception:

{{{
ValueError: Need 2 values to unpack in for loop; got 1.
}}}

The console gets flooded with the tracedumps and the upstream eventually
receives a `502 Bad Gateway`.

This is because `TECHNICAL_500_TEXT_TEMPLATE` iterates QueryDict this way:

{{{
{% for k, v in request.GET.items %} ... {{ k }} ... {{ v }} ...
}}}

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

Django

unread,
Sep 7, 2016, 7:23:00 AM9/7/16
to django-...@googlegroups.com
#27191: Generation of error reports fails if request.GET, POST, FILES or COOKIES
contains key 'items'
-------------------------------+--------------------------------------

Reporter: anatolyrr | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

[https://github.com/django/django/pull/7215 PR] with tests and the fix.

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

Django

unread,
Sep 7, 2016, 9:28:21 AM9/7/16
to django-...@googlegroups.com
#27191: Generation of error reports fails if request.GET, POST, FILES or COOKIES
contains key 'items'
---------------------------------+------------------------------------

Reporter: anatolyrr | Owner: nobody
Type: Bug | Status: new
Component: Error reporting | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* has_patch: 0 => 1
* component: Uncategorized => Error reporting
* stage: Unreviewed => Accepted


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

Django

unread,
Sep 7, 2016, 1:53:49 PM9/7/16
to django-...@googlegroups.com
#27191: Generation of error reports fails if request.GET, POST, FILES or COOKIES
contains key 'items'
---------------------------------+------------------------------------
Reporter: anatolyrr | Owner: nobody
Type: Bug | Status: closed

Component: Error reporting | Version: 1.10
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"7b6dccc82fa5b03cf431742c0655e5ac954e228e" 7b6dccc8]:
{{{
#!CommitTicketReference repository=""
revision="7b6dccc82fa5b03cf431742c0655e5ac954e228e"
Fixed #27191 -- Fixed debug view crash for requests with 'items' in
GET/POST/COOKIES/FILES.
}}}

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

Reply all
Reply to author
Forward
0 new messages