Merge lp://staging/~sinzui/lazr.restful/component-lookup-error-404 into lp://staging/lazr.restful

Proposed by Curtis Hovey
Status: Merged
Approved by: j.c.sackett
Approved revision: 207
Merged at revision: 204
Proposed branch: lp://staging/~sinzui/lazr.restful/component-lookup-error-404
Merge into: lp://staging/lazr.restful
Diff against target: 173 lines (+64/-29)
4 files modified
src/lazr/restful/NEWS.txt (+5/-0)
src/lazr/restful/publisher.py (+25/-26)
src/lazr/restful/tests/test_navigation.py (+33/-2)
src/lazr/restful/version.txt (+1/-1)
To merge this branch: bzr merge lp://staging/~sinzui/lazr.restful/component-lookup-error-404
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+138534@code.staging.launchpad.net

Commit message

Convert API traversal ComponentLookupErrors to NotFound.

Description of the change

An oops is reported when getPublishedSources distro_series has extra slash.
    ComponentLookupError: (
        (<lazr.restful.declarations.DistroSeriesEntry_1_0Adapter>,
         <canonical.launchpad.webapp.servers.WebServiceClientRequest
            instance URL=http://1.0/ubuntu/natty/>),
        <InterfaceClass lazr.restful.interfaces._rest.IEntry>)

This error happens in WebServicePublicationMixin.getResouce() which
we expect to raise a NotFound error.

RULES

    Pre-implementation: no one
    * This error happens because it getResource assumes anything that
      implements IEntry or IEntryField can be adapted to the underling
      object to make the resource. This is not always true because
      lazr.restful decorators declare parameter types.
    * The method raises NotFound if nothing an be adapted, but since
      it cannot be certain it's checks are correct, it needs to
      watch for ComponentLookupError and change it to NotFound.

QA

    On qastaging after it was updated to use lazr.restful 0.19.10
    * Verify https://api.qastaging.launchpad.net/devel/ubuntu/+archive/primary?distro_series=%2Fubuntu%2Fnatty%2F&exact_match=true&source_name=%22bzr%22&status=Published&ws.op=getPublishedSources&ws.size=1
      does not oops.

LINT

    src/lazr/restful/publisher.py
    src/lazr/restful/tests/test_navigation.py

TEST

    ./bin/test -vc -t NavigationTestCase

IMPLEMENTATION

I wrapped the entire if-elif block in a try-except to convert the error
into a NotFound error.
    src/lazr/restful/publisher.py
    src/lazr/restful/tests/test_navigation.py

To post a comment you must log in.
206. By Curtis Hovey

Fix comment.

207. By Curtis Hovey

Updated version for release.

Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches