[Django] #27005: request.body raises an exception

73 views
Skip to first unread message

Django

unread,
Aug 3, 2016, 6:22:34 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------
Reporter: dvinegla | 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
-------------------------------+--------------------
invalid literal for int() with base 10: ''

/site-packages/django/http/request.py in body

line 267

{{{
#!python

# request.META['CONTENT_LENGTH'] = ''

int(self.META.get('CONTENT_LENGTH', 0)) >
settings.DATA_UPLOAD_MAX_MEMORY_SIZE):
}}}

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

Django

unread,
Aug 3, 2016, 6:28:30 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------------------------

Reporter: dvinegla | 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 bmispelon):

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


Comment:

Hi,

Thanks for reporting this issue to us.
Could you provide some information on how you managed to trigger this
error? A full traceback would also be helpful.

Thanks.

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

Django

unread,
Aug 3, 2016, 6:51:14 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------------------------

Reporter: dvinegla | 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
-------------------------------+--------------------------------------

Comment (by dvinegla):

{{{
Environment:


Request Method: GET
Request URL: http://localhost:8000/myapp/

Django Version: 1.10
Python Version: 2.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "./python2.7/site-packages/django/core/handlers/exception.py" in
inner
39. response = get_response(request)

File "./python2.7/site-packages/django/core/handlers/base.py" in
_get_response
187. response = self.process_exception_by_middleware(e,
request)

File "./python2.7/site-packages/django/core/handlers/base.py" in
_get_response
185. response = wrapped_callback(request,
*callback_args, **callback_kwargs)

File "/testproject/myapp/views.py" in test_view
7. assert False, request.body

File "./python2.7/site-packages/django/http/request.py" in body
267. int(self.META.get('CONTENT_LENGTH', 0)) >
settings.DATA_UPLOAD_MAX_MEMORY_SIZE):

Exception Type: ValueError at /myapp/
Exception Value: invalid literal for int() with base 10: ''

}}}

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

Django

unread,
Aug 3, 2016, 7:08:57 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------------------------

Reporter: dvinegla | 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
-------------------------------+--------------------------------------

Comment (by dvinegla):

https://github.com/django/django/commit/929684d6ee0efb5afad51dc584489d0437d2451b
#diff-0eb6c5000a61126731553169fddb306eR267

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

Django

unread,
Aug 3, 2016, 7:12:12 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------------------------

Reporter: dvinegla | 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
-------------------------------+--------------------------------------

Comment (by bmispelon):

Could you also show us what `testproject.myapp.views.test_view` looks
like?

Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:4>

Django

unread,
Aug 3, 2016, 7:14:43 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------------------------

Reporter: dvinegla | 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
-------------------------------+--------------------------------------

Comment (by dvinegla):

{{{
from django.shortcuts import render

# Create your views here.


def test_view(request):

assert False, request.body


}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:5>

Django

unread,
Aug 3, 2016, 7:34:49 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception
-------------------------------+--------------------------------------

Reporter: dvinegla | 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
-------------------------------+--------------------------------------

Comment (by dvinegla):

{{{#!python
# testproject/testproject/urls.py

"""testproject URL Configuration

The `urlpatterns` list routes URLs to views. For more information please
see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url,
include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
url(r'^myapp/', include('myapp.urls')),
url(r'^admin/', admin.site.urls),
]

}}}

{{{#!python
# testproject/myapp/urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
url(r'^$', views.test_view),
]

}}}

{{{#!python
# testproject/myapp/views.py

from django.shortcuts import render

# Create your views here.


def test_view(request):

assert False, request.body

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:6>

Django

unread,
Aug 3, 2016, 8:43:20 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
---------------------------------+------------------------------------

Reporter: dvinegla | Owner: nobody
Type: Bug | Status: new
Component: HTTP handling | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* component: Uncategorized => HTTP handling
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:7>

Django

unread,
Aug 3, 2016, 9:10:28 AM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
---------------------------------+------------------------------------

Reporter: dvinegla | Owner: nobody
Type: Bug | Status: new
Component: HTTP handling | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by bmispelon):

If it helps, here's a small testcase that reproduces the issue (it works
on 1.9 but fails on 1.10):

{{{#!python
from django.test import TestCase, RequestFactory

class ReproTestCase(TestCase):
def test_repro(self):
request = RequestFactory().get('/', CONTENT_LENGTH='')
self.assertEqual(request.META['CONTENT_LENGTH'], '')
self.assertFalse(request.body)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:8>

Django

unread,
Aug 3, 2016, 12:28:27 PM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
---------------------------------+-------------------------------------
Reporter: dvinegla | Owner: timgraham
Type: Bug | Status: assigned

Component: HTTP handling | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => assigned
* owner: nobody => timgraham


--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:9>

Django

unread,
Aug 3, 2016, 12:57:56 PM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
---------------------------------+-------------------------------------
Reporter: dvinegla | Owner: timgraham
Type: Bug | Status: assigned
Component: HTTP handling | Version: 1.10
Severity: Release blocker | 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


Comment:

[https://github.com/django/django/pull/7016 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:10>

Django

unread,
Aug 3, 2016, 1:03:31 PM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
-------------------------------------+-------------------------------------

Reporter: dvinegla | Owner: timgraham
Type: Bug | Status: assigned
Component: HTTP handling | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* stage: Accepted => Ready for checkin


Comment:

Looks good to me, thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:11>

Django

unread,
Aug 3, 2016, 2:01:02 PM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
-------------------------------------+-------------------------------------
Reporter: dvinegla | Owner: timgraham
Type: Bug | Status: closed

Component: HTTP handling | Version: 1.10
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
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: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"5c63b3e5a797102d915e1683971517f747a28013" 5c63b3e5]:
{{{
#!CommitTicketReference repository=""
revision="5c63b3e5a797102d915e1683971517f747a28013"
Fixed #27005 -- Fixed crash if request.META[''CONTENT_LENGTH']=''.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:12>

Django

unread,
Aug 3, 2016, 2:25:54 PM8/3/16
to django-...@googlegroups.com
#27005: request.body raises an exception if 'CONTENT_LENGTH' = ''
-------------------------------------+-------------------------------------
Reporter: dvinegla | Owner: timgraham
Type: Bug | Status: closed
Component: HTTP handling | Version: 1.10
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"dcebeea2703322bc53c511bf3cff9e3c2e04d802" dcebeea]:
{{{
#!CommitTicketReference repository=""
revision="dcebeea2703322bc53c511bf3cff9e3c2e04d802"
[1.10.x] Fixed #27005 -- Fixed crash if
request.META[''CONTENT_LENGTH']=''.

Backport of 5c63b3e5a797102d915e1683971517f747a28013 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27005#comment:13>

Reply all
Reply to author
Forward
0 new messages