3427: "ValueError: too many values to unpack" when upload a pdf file

ra***@mt.c***** (Google Code) (Is this you? Claim this profile.)
david
david
July 20, 2014
What version are you running?

1.7.5, but also reproducible on demo site (2.0.3)

What's the URL of the page containing the problem?

When view a review request (my.reviewsboard/r/xxxx/)

What steps will reproduce the problem?
1. Create a review request
2. Upload a PDF file


What is the expected output? What do you see instead?

File should be uploaded correctly, instead it return a 500 internal error

What operating system are you using? What browser?
Linux (Mint 16), Firefox 29.0

Please provide any additional information below.

I provide a pdf that cause the trouble.

I think the mimetype is wrong. If login admin to check file attachment, the mimetype is "text/text/application/pdf"


here is part of the log

[Thu Jun 19 10:21:06 2014] [error]     value = self._resolve_lookup(context)
[Thu Jun 19 10:21:06 2014] [error]   File "/usr/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/template/base.py", line 754, in _resolve_lookup
[Thu Jun 19 10:21:06 2014] [error]     current = getattr(current, bit)
[Thu Jun 19 10:21:06 2014] [error]   File "/usr/lib/python2.7/site-packages/ReviewBoard-1.7.5-py2.7.egg/reviewboard/attachments/models.py", line 32, in review_ui
[Thu Jun 19 10:21:06 2014] [error]     self._review_ui = FileAttachmentReviewUI.for_type(self)
[Thu Jun 19 10:21:06 2014] [error]   File "/usr/lib/python2.7/site-packages/ReviewBoard-1.7.5-py2.7.egg/reviewboard/reviews/ui/base.py", line 168, in for_type
[Thu Jun 19 10:21:06 2014] [error]     mimetype = mimeparse.parse_mime_type(attachment.mimetype)
[Thu Jun 19 10:21:06 2014] [error]   File "/usr/lib/python2.7/site-packages/mimeparse-0.1.3-py2.7.egg/mimeparse.py", line 38, in parse_mime_type
[Thu Jun 19 10:21:06 2014] [error]     (type, subtype) = full_type.split("/")
[Thu Jun 19 10:21:06 2014] [error] ValueError: too many values to unpack
chipx86
#1 chipx86
I can't reproduce this on the demo server. I think what you saw there was an entirely separate issue. It's also a very strange one that I'm pretty sure nobody has reported to us before.

Can you provide the entire traceback?
  • +NeedInfo
#2 ra***@mt.c***** (Google Code) (Is this you? Claim this profile.)
How I reproduce:
================

1. Create a review that has no Repository (file attachments only)
2. upload the PDF I attached in previous comment

Error will occur when I hit upload button.

However, it only happens when I use Firefox(even with safe-mode) on my pc, Chrome/Chromium works fine. I cannot reproduce on my coworkers' computers, which are Lubuntu/Win Vista.

I also upload a file attachments screenshot, files that contains malformed MIME type are the one that cause error, but all files are the same file.

Entire traceback:
=================

[Mon Jun 23 05:48:08 2014] [error] ERROR:django.request:Internal Server Error: /api/review-requests/1498/file-attachments/
[Mon Jun 23 05:48:08 2014] [error] Traceback (most recent call last):
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/core/handlers/base.py", line 188, in get_response
[Mon Jun 23 05:48:08 2014] [error]     response = middleware_method(request, response)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Django-1.4.5-py2.7.egg/django/middleware/http.py", line 14, in process_response
[Mon Jun 23 05:48:08 2014] [error]     response['Content-Length'] = str(len(response.content))
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Djblets-0.7.10-py2.7.egg/djblets/webapi/core.py", line 281, in _get_content
[Mon Jun 23 05:48:08 2014] [error]     content = adapter.encode(self.api_data, request=self.request)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Djblets-0.7.10-py2.7.egg/djblets/webapi/core.py", line 88, in encode
[Mon Jun 23 05:48:08 2014] [error]     return super(JSONEncoderAdapter, self).encode(o)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib64/python2.7/site-packages/simplejson/encoder.py", line 226, in encode
[Mon Jun 23 05:48:08 2014] [error]     chunks = self.iterencode(o, _one_shot=True)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib64/python2.7/site-packages/simplejson/encoder.py", line 296, in iterencode
[Mon Jun 23 05:48:08 2014] [error]     return _iterencode(o, 0)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Djblets-0.7.10-py2.7.egg/djblets/webapi/core.py", line 96, in default
[Mon Jun 23 05:48:08 2014] [error]     result = self.encoder.encode(o, *self.encode_args, **self.encode_kwargs)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Djblets-0.7.10-py2.7.egg/djblets/webapi/core.py", line 261, in encode
[Mon Jun 23 05:48:08 2014] [error]     result = encoder.encode(*args, **kwargs)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Djblets-0.7.10-py2.7.egg/djblets/webapi/encoders.py", line 48, in encode
[Mon Jun 23 05:48:08 2014] [error]     return resource.serialize_object(o, *args, **kwargs)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/Djblets-0.7.10-py2.7.egg/djblets/webapi/resources.py", line 918, in serialize_object
[Mon Jun 23 05:48:08 2014] [error]     value = getattr(obj, field)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/ReviewBoard-1.7.5-py2.7.egg/reviewboard/attachments/models.py", line 57, in icon_url
[Mon Jun 23 05:48:08 2014] [error]     return self.mimetype_handler.get_icon_url()
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/ReviewBoard-1.7.5-py2.7.egg/reviewboard/attachments/models.py", line 26, in mimetype_handler
[Mon Jun 23 05:48:08 2014] [error]     return MimetypeHandler.for_type(self)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/ReviewBoard-1.7.5-py2.7.egg/reviewboard/attachments/mimetypes.py", line 139, in for_type
[Mon Jun 23 05:48:08 2014] [error]     mimetype = mimeparse.parse_mime_type(attachment.mimetype)
[Mon Jun 23 05:48:08 2014] [error]   File "/usr/lib/python2.7/site-packages/mimeparse-0.1.3-py2.7.egg/mimeparse.py", line 38, in parse_mime_type
[Mon Jun 23 05:48:08 2014] [error]     (type, subtype) = full_type.split("/")
[Mon Jun 23 05:48:08 2014] [error] ValueError: too many values to unpack


chipx86
#3 chipx86
I don't know off-hand, but the very first thing I'd want you to do before looking into it further is to upgrade to a modern version of Review Board. So much has changed since the early 1.7 releases.
david
#4 david
Something about those mimetypes is also very wrong. "text/text/application/pdf" is not a correctly-formatted mimetype.
david
#5 david
I'm going to make a change to not trust the browser-provided mimetype if it's not valid.
  • -NeedInfo
    +PendingReview
  • +Component-Attachments
  • +david
david
#6 david
Fixed in release-2.0.x (928eb49). Thanks!
  • -PendingReview
    +Fixed