fix review_types argument of the API's Branch.createMergeProposal method

Bug #520412 reported by Markus Korn
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
Leonard Richardson

Bug Description

The reviewers and the review_types argument of the Branch.createMergeProposal method must have the same length as zip() is used to generate the review_requests argument for addLandingTarget. Right now a ValueError is raised if this is not the case. However this ValueError is not well exposed over the API, it just appears as a 500 Internal Error with no additional explaination. On the other hand this behavior is different to the behavior of the web interface, where the review type argument is optional.

To fix this bug there are tow possible solutions:
 * make the types optional too, by appending emtpy strings to the review_types list like
      review_types += [""]*(len(reviewers) - len(review_types))
 * or expose the ValueError as a 400 Bad Request with some verbose information

Current error representation:

In [7]: b.createMergeProposal (target_branch=trunk, reviewers=[launchpad.me.self_link,])
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)

/media/devel/ilaunchpad-shell/trunk/<ipython console> in <module>()

/usr/lib/python2.6/dist-packages/lazr/restfulclient/resource.pyc in __call__(self, *args, **kwargs)
    458 extra_headers = { 'Content-type' : media_type }
    459 response, content = self.root._browser._request(
--> 460 url, in_representation, http_method, extra_headers=extra_headers)
    461
    462 if response.status == 201:

/usr/lib/python2.6/dist-packages/lazr/restfulclient/_browser.pyc in _request(self, url, data, method, media_type, extra_headers)
    202 # Turn non-2xx responses into exceptions.

    203 if response.status // 100 != 2:
--> 204 raise HTTPError(response, content)
    205 return response, content
    206

HTTPError: HTTP Error 500: Internal Server Error
---------------------------------------------------------------------------
Response: {'connection': 'close',
 'content-length': '10',
 'content-type': 'text/plain',
 'date': 'Thu, 11 Feb 2010 11:38:19 GMT',
 'server': 'zope.server.http (HTTP)',
 'status': '500',
 'via': '1.1 wildcard.staging.launchpad.net',
 'x-lazr-oopsid': 'OOPS-1503S125',
 'x-powered-by': 'Zope (www.zope.org), Python (www.python.org)'}
Content: 'ValueError'
---------------------------------------------------------------------------

I'm happy to fix this bug, if someone tells me what the "correct" solutions would look like

Related branches

Aaron Bentley (abentley)
Changed in launchpad-code:
status: New → Triaged
importance: Undecided → High
tags: added: code-review oops
Revision history for this message
Tim Penhey (thumper) wrote :

Markus,

I think that the API exposed method should do detailed checking, and give a verbose error message if it is bad. The only thing I'm not sure on is how to make it not OOPS, but instead to return a known error.

Revision history for this message
Markus Korn (thekorn) wrote :

I started working on it in the attached branch.

@Tim: as far as I understand you last comment the solution would be to just expose the ValueError as a "HTTP 400 Bad Request"-error with some verbose information. So there won't be an empty string as default for each review_type

However there is still an issue with the attached solution, the testcase is failing, the error is still handled as an internal server error, so I need to investigate further.

Changed in launchpad-code:
assignee: nobody → Markus Korn (thekorn)
status: Triaged → In Progress
Changed in launchpad:
importance: High → Critical
Revision history for this message
Leonard Richardson (leonardr) wrote :

Hey, Markus, are you still working on this? If not, I may be able to take it off your hands.

Revision history for this message
Robert Collins (lifeless) wrote :

Unassigning : the branch from @markus may be useful, but its been a year since they took it on - its clearly stalled.

Changed in launchpad:
assignee: Markus Korn (thekorn) → nobody
Revision history for this message
Robert Collins (lifeless) wrote :

@Markus - sorry we didn't get back to you about this --much-- earlier.

Revision history for this message
Leonard Richardson (leonardr) wrote :

The code in Markus' branch was correct, but it didn't work due to a bug in lazr.restful that prevented webservice_error from working. The bug was fixed recently. I've ported Markus' branch to a modern Launchpad branch, and changed his doctest to a unit test.

Revision history for this message
Andrew Bennetts (spiv) wrote :

For some reason this bug is now affecting the UDD package importer, e.g. OOPS-1910A1064. The list of failing imports is: <http://package-import.ubuntu.com/status/7ae30b44f1f904e04bbae6700b7181dd.html>. Currently 51 imports are affected.

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 520412] Re: fix review_types argument of the API's Branch.createMergeProposal method

n Mon, Mar 28, 2011 at 12:41 PM, Andrew Bennetts
<email address hidden> wrote:
> For some reason this bug is now affecting the UDD package importer, e.g.
> OOPS-1910A1064.  The list of failing imports is: <http://package-
> import.ubuntu.com/status/7ae30b44f1f904e04bbae6700b7181dd.html>.
> Currently 51 imports are affected.

My first guess would be a bug in the package importer, based on the
defect fixed here.

Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
Changed in launchpad:
assignee: nobody → Leonard Richardson (leonardr)
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
tags: added: qa-ok
removed: qa-needstesting
William Grant (wgrant)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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