Opened 8 years ago

Closed 8 years ago

#27191 closed Bug (fixed)

Generation of error reports fails if request.GET, POST, FILES or COOKIES contains key 'items'

Reported by: Anatoly Burov Owned by: nobody
Component: Error reporting Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 }} ...

Change History (3)

comment:1 by Anatoly Burov, 8 years ago

PR with tests and the fix.

comment:2 by Tim Graham, 8 years ago

Component: UncategorizedError reporting
Has patch: set
Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 7b6dccc8:

Fixed #27191 -- Fixed debug view crash for requests with 'items' in GET/POST/COOKIES/FILES.

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