Opened 4 years ago

Closed 4 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 4 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 4 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 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.3-rc1 to 1.3

comment:2 Changed 4 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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 4 years ago by vkryachko

  • Resolution fixed deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Type set to 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 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from reopened to closed

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 4 years ago by vung

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

comment:5 Changed 4 years ago by vung

  • Has patch set
  • Resolution fixed deleted
  • Status changed from closed to reopened

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

Same thing happens in the mod_python handler.

comment:6 Changed 4 years ago by russellm

  • Easy pickings unset
  • Severity changed from Normal to Release blocker

comment:7 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from reopened to closed

In [16082]:

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

comment:8 Changed 4 years ago by jezdez

In [16083]:

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

Backport from trunk (r16082).

comment:9 Changed 4 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 4 years ago by kinpoo

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

comment:10 Changed 4 years ago by kinpoo

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Triage Stage changed from Accepted to Design decision needed

comment:11 Changed 4 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from reopened to closed

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