[Django] #31739: Document RawPostDataException

74 views
Skip to first unread message

Django

unread,
Jun 24, 2020, 6:16:40 AM6/24/20
to django-...@googlegroups.com
#31739: Document RawPostDataException
-------------------------------------------------+------------------------
Reporter: Adam (Chainz) Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------------+------------------------
When accessing HttpRequest.body it's possible that it will raise
RawPostDataException due to prior use of HttpRequest.read() / readline().
However there is no documentation covering this exception, nor any
guidance about solving it. Other exceptions like RequestDataTooBig are
covered.

Also the exception message is a little obscure: "You cannot access body
after reading from request's data stream" . What's the 'data stream' here?

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

Django

unread,
Jun 24, 2020, 6:16:47 AM6/24/20
to django-...@googlegroups.com
#31739: Document RawPostDataException
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |

Component: HTTP handling | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Adam (Chainz) Johnson):

* easy: 0 => 1


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

Django

unread,
Jun 25, 2020, 3:36:08 AM6/25/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.

-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | 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 Carlton Gibson):

* component: HTTP handling => Documentation
* easy: 1 => 0
* stage: Unreviewed => Accepted


Comment:

I'm not entirely convinced here...

* It's a bit generous to say `RequestDataTooBig` is documented. It's
mentioned, yes, but...
* IMO `request's data stream` is clear enough, since you're using the
stream IO API (`read()` &co.)
* Part of this stuff is undocumented because internal no?

But I guess we could add a note to the
[https://docs.djangoproject.com/en/3.0/ref/request-
response/#django.http.HttpRequest.read `HttpRequest.read()` docs] saying
something like, "if read() is used prior to accessing body, body will no
longer be available." The body docs link to `read()` saying "see more",
but then there's nothing said so some expansion might be good.

(Given that all the stream IO methods have the same issue, perhaps the
note needs to be in the `body` docs.)

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

Django

unread,
Jun 28, 2020, 6:42:18 AM6/28/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: nobody
Johnson |
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | 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 Adam (Chainz) Johnson):

> It's a bit generous to say RequestDataTooBig is documented

Yes that's true. But at least one can search for it in the docs and find a
sentence.

> IMO request's data stream is clear enough, since you're using the stream
IO API (`read()` &co.)

It's not always clear that the streaming API has been read, as the body
can be read by some other code. The issue came up for me when trying to
access `.body` after django-rest-framework had used `.read()`.

> Part of this stuff is undocumented because internal no?

I don't think this is internal - these are exceptions that users can see
when trying to use the public interface in `.body` / `read()` etc.

I think only a few sentences are needed to describe the possible problems
so that anyone trying to debug similar issues has more information to go
on.

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

Django

unread,
Jul 8, 2020, 12:31:38 AM7/8/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Tim Park
Johnson |
Type: | Status: assigned

Cleanup/optimization |
Component: Documentation | Version: master
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 felixxm):

* owner: nobody => Tim Park
* status: new => assigned
* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Jul 8, 2020, 3:46:51 AM7/8/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Tim Park
Johnson |
Type: | Status: assigned
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | 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 Carlton Gibson):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jul 8, 2020, 4:40:59 AM7/8/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Tim Park
Johnson |
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | 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 GitHub <noreply@…>):

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


Comment:

In [changeset:"060576b0abac460d72714e300aa709d1e7a87dd7" 060576b0]:
{{{
#!CommitTicketReference repository=""
revision="060576b0abac460d72714e300aa709d1e7a87dd7"
Fixed #31739 -- Documented dependency between HttpRequest stream IO
methods and body.
}}}

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

Django

unread,
Jul 8, 2020, 4:41:56 AM7/8/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Tim Park
Johnson |
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | 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 Carlton Gibson <carlton.gibson@…>):

In [changeset:"3756a0509ae48d91070fb65921dbb2d2155c61d1" 3756a05]:
{{{
#!CommitTicketReference repository=""
revision="3756a0509ae48d91070fb65921dbb2d2155c61d1"
[3.1.x] Fixed #31739 -- Documented dependency between HttpRequest stream
IO methods and body.

Backport of 060576b0abac460d72714e300aa709d1e7a87dd7 from master
}}}

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

Django

unread,
Jul 8, 2020, 4:42:23 AM7/8/20
to django-...@googlegroups.com
#31739: Document dependency between HttpRequest stream IO methods and body.
-------------------------------------+-------------------------------------
Reporter: Adam (Chainz) | Owner: Tim Park
Johnson |
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | 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 Carlton Gibson <carlton.gibson@…>):

In [changeset:"502349ce77a2bbf86ec33891c37f2ee9e087d520" 502349ce]:
{{{
#!CommitTicketReference repository=""
revision="502349ce77a2bbf86ec33891c37f2ee9e087d520"
[3.0.x] Fixed #31739 -- Documented dependency between HttpRequest stream
IO methods and body.

Backport of 060576b0abac460d72714e300aa709d1e7a87dd7 from master
}}}

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

Reply all
Reply to author
Forward
0 new messages