API oopsing with UnicodeEncodeError

Bug #262328 reported by Ursula Junque
2
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Leonard Richardson

Bug Description

As seen on OOPS-970EA148 and OOPS-970EA149, API is oopsing when trying to handle some unicode chars:

UnicodeEncodeError: 'ascii' codec can't encode character u'\\xe1' in position 1: ordinal not in range(128)

Revision history for this message
Brad Crittenden (bac) wrote :

The OOPS was triggered trying to retrieve a project that has UNICODE in its display name, title, and summary:
https://edge.launchpad.net/sachco

This is the client-side query that caused the OOPS (where 'lp' is a launchpad object):

>>> lp.projects['sachco']
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/bac/canonical/lp-branches/ws_ps/lib/launchpadlib/resource.py", line 534, in __getitem__
    representation = simplejson.loads(self._root._browser.get(url))
  File "/home/bac/canonical/lp-branches/ws_ps/lib/launchpadlib/_browser.py", line 180, in get
    response, content = self._request(url)
  File "/home/bac/canonical/lp-branches/ws_ps/lib/launchpadlib/_browser.py", line 170, in _request
    raise HTTPError(response, content)
launchpadlib.errors.HTTPError: HTTP Error 500: Internal Server Error
>>>

And here is the value of 'content' from the exception:

(Pdb) print e.content
'ascii' codec can't encode character u'\xe1' in position 1: ordinal not in range(128)

Traceback (most recent call last):
  File "/srv/edge.launchpad.net/edge/launchpad/lib/zope/publisher/publish.py", line 138, in publish
    result = publication.callObject(request, object)
  File "/srv/edge.launchpad.net/edge/launchpad/lib/canonical/launchpad/webapp/publication.py", line 327, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  File "/srv/edge.launchpad.net/edge/launchpad/lib/zope/publisher/publish.py", line 113, in mapply
    return debug_call(object, args)
  File "/srv/edge.launchpad.net/edge/launchpad/lib/zope/publisher/publish.py", line 119, in debug_call
    return object(*args)
  File "/srv/edge.launchpad.net/edge/launchpad/lib/canonical/lazr/rest/resource.py", line 460, in __call__
    return self.do_GET()
  File "/srv/edge.launchpad.net/edge/launchpad/lib/canonical/lazr/rest/resource.py", line 579, in do_GET
    media_type = self.handleConditionalGET()
  File "/srv/edge.launchpad.net/edge/launchpad/lib/canonical/lazr/rest/resource.py", line 160, in handleConditionalGET
    existing_etag = self.getETag(media_type)
  File "/srv/edge.launchpad.net/edge/launchpad/lib/canonical/lazr/rest/resource.py", line 512, in getETag
    values.append(str(value))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 1: ordinal not in range(128)

Changed in launchpad:
assignee: nobody → leonardr
importance: Undecided → High
milestone: none → 2.1.9
status: New → Triaged
Revision history for this message
Leonard Richardson (leonardr) wrote :

Revision 6923 includes a fix for this bug.

Changed in launchpad:
status: Triaged → Fix Committed
Changed in launchpad-foundations:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.