#32329: CSRF failure incorrectly reported on upload when there is a problem with
storage
------------------------------------+------------------------------------
     Reporter:  IO                  |                    Owner:  nobody
         Type:  Bug                 |                   Status:  new
    Component:  CSRF                |                  Version:  3.1
     Severity:  Normal              |               Resolution:
     Keywords:  uploads csrf admin  |             Triage Stage:  Accepted
    Has patch:  0                   |      Needs documentation:  0
  Needs tests:  0                   |  Patch needs improvement:  0
Easy pickings:  0                   |                    UI/UX:  0
------------------------------------+------------------------------------

Comment (by Virtosu Bogdan):

 I reproduced the error in ticket:20128 and it seems to be raised from
 
[https://github.com/django/django/blob/012f38f9594b35743e9ab231757b7b62db638323/django/http/request.py#L359
 django/http/request.py #359]
 {{{
 #!python
 Traceback (most recent call last):
   File "/project/django/django/middleware/csrf.py", line 345, in
 _check_token
     request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
   File "/project/django/django/core/handlers/wsgi.py", line 102, in
 _get_post
     self._load_post_and_files()
   File "/project/django/django/http/request.py", line 328, in
 _load_post_and_files
     self._post, self._files = self.parse_file_upload(self.META, data)
   File "/project/django/django/http/request.py", line 288, in
 parse_file_upload
     return parser.parse()
   File "/project/django/django/http/multipartparser.py", line 240, in
 parse
     for chunk in field_stream:
   File "/project/django/django/http/multipartparser.py", line 402, in
 __next__
     output = next(self._producer)
   File "/project/django/django/http/multipartparser.py", line 534, in
 __next__
     for bytes in stream:
   File "/project/django/django/http/multipartparser.py", line 402, in
 __next__
     output = next(self._producer)
   File "/project/django/django/http/multipartparser.py", line 465, in
 __next__
     data = self.flo.read(self.chunk_size)
   File "/project/django/django/http/request.py", line 359, in read
     raise UnreadablePostError(*e.args) from e
 django.http.request.UnreadablePostError: Apache/mod_wsgi request data read
 error: Partial results are valid but processing is incomplet
 }}}

 As it was suggested, catching `UnreadablePostError` instead of `OSError`
 fixes this ticket and still conforms to ticket:20128. Only the test from
 that ticket needs to be updated.


 I was wondering if logging the ignored exception wouldn't be enough as an
 alternative. Figuring out the issue from logs seems to be the main
 reported issue.

 Please let me know if any of these solutions is acceptable

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.89027802b8870d6c808d4110bd419179%40djangoproject.com.

Reply via email to