Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

ValueError: dictionary update sequence element #0 has length 1; 2 is required #533

Closed
chadwhitacre opened this issue Jan 28, 2013 · 9 comments

Comments

@chadwhitacre
Copy link
Contributor

https://app.getsentry.com/gittip/gittip/group/3352951/

Traceback (most recent call last):
  File "aspen/website.py", line 66, in handle_safely
    response = self.handle(request)
  File "aspen/website.py", line 99, in handle
    response = request.resource.respond(request)
  File "aspen/resources/dynamic_resource.py", line 57, in respond
    response = self.get_response(context)
  File "aspen/resources/negotiated_resource.py", line 86, in get_response
    media_type = mimeparse.best_match(self.available_types, accept)
  File "site-packages/mimeparse.py", line 121, in best_match
    parsed_header = [parse_media_range(r) for r in _filter_blank(header.split(","))]
  File "site-packages/mimeparse.py", line 54, in parse_media_range
    (type, subtype, params) = parse_mime_type(range)
  File "site-packages/mimeparse.py", line 33, in parse_mime_type
    for param in parts[1:] ])
ValueError: dictionary update sequence element #0 has length 1; 2 is required
@chadwhitacre
Copy link
Contributor Author

I can't reproduce this. So far my hypothesis is that this is indicative of Heroku moving the ground out from beneath our feet.

@zbynekwinkler
Copy link
Contributor

>>> import mimeparse
>>> mimeparse.best_match(['text/html'], 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;')

These are the params best_match is called with (taken from the sentry page traceback). I guess this is a bug in the mimeparse module. That function should not raise anything, right?

Googling for the problem reveals:
falconry/python-mimeparse#2
http://code.google.com/p/mimeparse/issues/detail?id=11

Unfortunately it is not fixed yet 😢

@zbynekwinkler
Copy link
Contributor

Referencing #1521 to link them together.

@pjz
Copy link

pjz commented Oct 8, 2013

Technically that Accept: header is malformed; the trailing semicolon is disallowed since there're no quality parameters after it.

@zbynekwinkler
Copy link
Contributor

Can we fix this in aspen? Like guarding against exceptions raised by mimeparse.best_match. I agree that the header is malformed but lets follow http://en.wikipedia.org/wiki/Robustness_principle.

@chadwhitacre
Copy link
Contributor Author

@zwn Let's ticket in Aspen if we haven't already.

@chadwhitacre
Copy link
Contributor Author

Is this solved?

@pjz
Copy link

pjz commented Jan 8, 2014

The aspen side was solved 3 months ago.

@chadwhitacre
Copy link
Contributor Author

We last saw this 10 days ago, just before we landed the aspen 0.28 upgrade (#1699). Before that we were on 0.26.1, and the commit log on aspen-python shows that AspenWeb/pando.py#260 landed after 0.26.1 was released. The sentry error is already resolved. I'm closing this as fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants