Opened 6 years ago

Closed 5 years ago

#15672 closed Bug (fixed)

wsgi handler bug in 1.3

Reported by: vkryachko Owned by: vkryachko
Component: Core (Other) Version: 1.3
Severity: Release blocker Keywords:
Cc: kinpoo Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When environ cannot be parsed, the following exception i raised:

File "/var/www/dynamic/virtualenv/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 264, in call

logger.warning('Bad Request (UnicodeDecodeError): %s' % request.path,

UnboundLocalError: local variable 'request' referenced before assignment

Attachments (2)

ticket-15672.diff (2.1 KB) - added by vung 6 years ago.
Removes references to request in the wsgi and mod_python handlers and adds a test
ticket-15672-force_unicode-with-ignore.diff (3.2 KB) - added by kinpoo 5 years ago.
ignore UnicodeDecodeError, does not handle it as bad request, let handle it as 404

Download all attachments as: .zip

Change History (13)

comment:1 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted
Version: 1.3-rc11.3

comment:2 Changed 6 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

In [15918]:

Fixed #15672 -- Fixed bug in core/handlers/wsgi.py where we were referring to the 'request' variable before assigning to it. Thanks for the report, vkryachko

comment:3 Changed 6 years ago by vkryachko

Resolution: fixed
Severity: Normal
Status: closedreopened
Type: Bug

Thanks for the fix, adrian. But looking at the 1.3.x branch, I see that this fix has not been backported there, so I think the issue has to be reopened. I would have backported it myself, but I don't have write access to the SVN. Regards

comment:4 Changed 6 years ago by Russell Keith-Magee

Resolution: fixed
Status: reopenedclosed

In [16009]:

[1.3.X] Fixed #15672 -- Fixed bug in core/handlers/wsgi.py where we were referring to the 'request' variable before assigning to it. Thanks for the report, vkryachko

Backport of r15918 from trunk.

Changed 6 years ago by vung

Attachment: ticket-15672.diff added

Removes references to request in the wsgi and mod_python handlers and adds a test

comment:5 Changed 6 years ago by vung

Has patch: set
Resolution: fixed
Status: closedreopened

'request' was referenced twice so the bug is still present (see test)

Same thing happens in the mod_python handler.

comment:6 Changed 6 years ago by Russell Keith-Magee

Easy pickings: unset
Severity: NormalRelease blocker

comment:7 Changed 6 years ago by Jannis Leidel

Resolution: fixed
Status: reopenedclosed

In [16082]:

Fixed #15672 -- Refined changes made in r15918. Thanks, vung.

comment:8 Changed 6 years ago by Jannis Leidel

In [16083]:

[1.3.X] Fixed #15672 -- Refined changes made in r15918. Thanks, vung.

Backport from trunk (r16082).

comment:9 Changed 5 years ago by kinpoo

Cc: kinpoo added
UI/UX: unset
  1. I think it might be handle as a bad URL and output 404 not found, but not 400 bad request.
  1. Sometimes, add some unnecessary information in URL for SEO reason, example: "/123-外贸", encoded as "/123-%E5%A4%96%E8%B4%B8", if it broken, looks like "/123-%E5", I can also get the correct resource and redirect to correct url.

Changed 5 years ago by kinpoo

ignore UnicodeDecodeError, does not handle it as bad request, let handle it as 404

comment:10 Changed 5 years ago by kinpoo

Resolution: fixed
Status: closedreopened
Triage Stage: AcceptedDesign decision needed

comment:11 Changed 5 years ago by Karen Tracey

Resolution: fixed
Status: reopenedclosed

This ticket was about a straightforward bug: use of a variable before it had been set. The recent comments and re-opening of this ticket don't seem related to that simple bug, which has been fixed. If you think this area of the code has some other problem please open a new ticket to track that. Reclosing this ticket as fixed, because the UnboundLocalError has been fixed.

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