requesting user's mugshot via api OOPS when user is using the default one

Bug #336943 reported by Markus Korn
4
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

Trying to get the mugshot of an user who is using the default one results in a 404 error and raises an OOPS. This should either return None or the default one.

In [1]: ajmitch = launchpad.people["ajmitch"]
send: 'GET /beta/~ajmitch HTTP/1.1\r\nHost: api.edge.launchpad.net:443\r\nAccept-Encoding: identity\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="13892994", oauth_timestamp="1236031826", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="XXXXX", oauth_signature="&YYYYY"\r\nif-none-match: "231c4eae421edb15d9ab0b6828256410bcfc3604"\r\nte: deflate, gzip\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 304 Not Modified\r\n'
header: Date: Mon, 02 Mar 2009 22:10:27 GMT
header: Server: zope.server.http (HTTP)
header: Etag: "231c4eae421edb15d9ab0b6828256410bcfc3604"
header: Vary: Cookie,Authorization,Accept

In [2]: ajmitch.mugshot.open()
send: 'GET /beta/~ajmitch/mugshot HTTP/1.1\r\nHost: api.edge.launchpad.net:443\r\nAccept-Encoding: identity\r\nte: deflate, gzip\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="41296980", oauth_timestamp="1236031831", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="XXXXX", oauth_signature="&YYYYY"\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Date: Mon, 02 Mar 2009 22:10:31 GMT
header: Server: zope.server.http (HTTP)
header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
header: X-Lazr-Oopsid: OOPS-1157ED150
header: Content-Type: text/plain
header: Content-Length: 108
header: Via: 1.1 wildcard.edge.launchpad.net
send: 'GET /beta/~ajmitch/mugshot HTTP/1.1\r\nHost: api.edge.launchpad.net:443\r\nAccept-Encoding: identity\r\nte: deflate, gzip\r\nAuthorization: OAuth realm="https://api.launchpad.net", oauth_nonce="61619593", oauth_timestamp="1236031831", oauth_consumer_key="just testing", oauth_signature_method="PLAINTEXT", oauth_version="1.0", oauth_token="XXXXX", oauth_signature="&YYYYY"\r\naccept: application/json\r\nuser-agent: Python-httplib2/$Rev: 259 $\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Date: Mon, 02 Mar 2009 22:10:32 GMT
header: Server: zope.server.http (HTTP)
header: X-Powered-By: Zope (www.zope.org), Python (www.python.org)
header: X-Lazr-Oopsid: OOPS-1157EB167
header: Content-Type: text/plain
header: Content-Length: 108
header: Via: 1.1 wildcard.edge.launchpad.net
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)

/home/markus/<ipython console> in <module>()

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/resource.pyc in open(self, mode, content_type, filename)
    730 """Open the file on the server for read or write access."""
    731 if mode in ('r', 'w'):
--> 732 return HostedFileBuffer(self, mode, content_type, filename)
    733 else:
    734 raise ValueError("Invalid mode. Supported modes are: r, w")

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/resource.pyc in __init__(self, hosted_file, mode, content_type, filename)
    755 "specify filename.")
    756 response, value = hosted_file._root._browser.get(
--> 757 self.url, return_response=True)
    758 content_type = response['content-type']
    759 last_modified = response['last-modified']

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/_browser.pyc in get(self, resource_or_uri, headers, return_response)
    220 method = resource_or_uri.get_method('get')
    221 url = method.build_request_url()
--> 222 response, content = self._request(url, extra_headers=headers)
    223 if return_response:
    224 return (response, content)

/media/disk-1/lp_api/launnchpadlib/trunk/launchpadlib/_browser.pyc in _request(self, url, data, method, media_type, extra_headers)
    210 # Turn non-2xx responses into exceptions.
    211 if response.status // 100 != 2:
--> 212 raise HTTPError(response, content)
    213 return response, content
    214

HTTPError: HTTP Error 404: Not Found
---------------------------------------------------------------------------
Response: {'content-length': '108',
 'content-type': 'text/plain',
 'date': 'Mon, 02 Mar 2009 22:10:32 GMT',
 'server': 'zope.server.http (HTTP)',
 'status': '404',
 'via': '1.1 wildcard.edge.launchpad.net',
 'x-lazr-oopsid': 'OOPS-1157EB167',
 'x-powered-by': 'Zope (www.zope.org), Python (www.python.org)'}
Content: "Object: <canonical.launchpad.rest.bytestorage.LibraryBackedByteStorage object at 0xb040dd0>, name: 'mugshot'"
---------------------------------------------------------------------------

In [3]:

Changed in launchpad-registry:
status: New → Triaged
Curtis Hovey (sinzui)
Changed in launchpad-registry:
importance: Undecided → Low
Revision history for this message
Curtis Hovey (sinzui) wrote :

The real oops is
  NotFound: Object: <canonical.launchpad.rest.bytestorage.LibraryBackedByteStorage object at 0xb040dd0>, name: 'mugshot'

    Traceback (most recent call last):
  Module zope.publisher.publish, line 133, in publish
    result = publication.callObject(request, obj)
  Module canonical.launchpad.webapp.servers, line 1234, in callObject
    value = super(WebServicePublication, self).callObject(
  Module canonical.launchpad.webapp.publication, line 354, in callObject
    return mapply(ob, request.getPositionalArguments(), request)
  Module zope.publisher.publish, line 108, in mapply
    return debug_call(obj, args)
   - __traceback_info__: <security proxied canonical.lazr.rest.bytestorage.ByteStorageResource instance at 0xb040650>
  Module zope.publisher.publish, line 114, in debug_call
    return obj(*args)
  Module canonical.lazr.rest.bytestorage, line 25, in __call__
    return self.do_GET()
  Module canonical.lazr.rest.bytestorage, line 55, in do_GET
    raise NotFound(self.context, self.context.filename, self.request)
NotFound: Object: <canonical.launchpad.rest.bytestorage.LibraryBackedByteStorage object at 0xb040dd0>, name: 'mugshot'

I have looked at the interface:
    MugshotImageUpload(
        title=_("Mugshot"), required=False, default_image_resource='/@@/person-mugshot', ...)

and the field BaseImageUpload. It does not appear to use default_image_resource after it is set in the __init__ method.
I think the getCurrentImage() method should set the current var to self.default_image_resource or something in the API must become much smarter about how to handle this situation.

Curtis Hovey (sinzui)
tags: added: users
removed: registry-people
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.