3521: RBTools Python API - can't pass interdiff_revision in /api/review-requests/{review_request_id}/diff-context/

SobMi******@gmai***** (Google Code) (Is this you? Claim this profile.)
david
david
Sept. 4, 2014
What version are you running?
RBTools version 0.6.2 | ReviewBoard version 2.0.2

What's the URL of the page containing the problem?
/api/review-requests/{review_request_id}/diff-context/ 

What steps will reproduce the problem?
sample code:
1. from rbtools.api.client import RBClient
2. client = RBClient("http://localhost/reviewboard")
3. root = client.get_root()
4. rq = root.get_review_request(review_request_id=3)
5. context = rq.get_diff_context(revision=1, interdiff_revision=1)

What is the expected output? What do you see instead?
A context of review request

What operating system are you using? What browser?
Linux Debian Jessie / Windows 7

Please provide any additional information below.

Traceback:
---------------------------------------------------------------------------
BadRequestError                           Traceback (most recent call last)
<ipython-input-7-940e0d500129> in <module>()
----> 1 context = rq.get_diff_context(revision=1, interdiff_revision=1)

/DOWTMP/env/lib/python2.7/site-packages/RBTools-0.6.2-py2.7.egg/rbtools/api/resource.pyc in <lambda>(resource, url, **kwargs)
    137                         "get_%s" % link,
    138                         lambda resource=self, url=body['href'], **kwargs: (
--> 139                             self._get_url(url, **kwargs)))
    140 
    141     def _wrap_field(self, field):

/DOWTMP/env/lib/python2.7/site-packages/RBTools-0.6.2-py2.7.egg/rbtools/api/decorators.pyc in request_method(self, *args, **kwargs)
     22 
     23             return self._transport.execute_request_method(method_wrapper,
---> 24                                                           *args, **kwargs)
     25 
     26     request_method.__name__ = f.__name__

/DOWTMP/env/lib/python2.7/site-packages/RBTools-0.6.2-py2.7.egg/rbtools/api/transport/sync.pyc in execute_request_method(self, method, *args, **kwargs)
     59 
     60         if isinstance(request, HttpRequest):
---> 61             return self._execute_request(request)
     62 
     63         return request

/DOWTMP/env/lib/python2.7/site-packages/RBTools-0.6.2-py2.7.egg/rbtools/api/transport/sync.pyc in _execute_request(self, request)
     68                                                         request.url))
     69 
---> 70         rsp = self.server.make_request(request)
     71         info = rsp.info()
     72         mime_type = info['Content-Type']

/DOWTMP/env/lib/python2.7/site-packages/RBTools-0.6.2-py2.7.egg/rbtools/api/request.pyc in make_request(self, request)
    482             rsp = urllib2.urlopen(r)
    483         except urllib2.HTTPError, e:
--> 484             self.process_error(e.code, e.read())
    485         except urllib2.URLError, e:
    486             raise ServerInterfaceError("%s" % e.reason)

/DOWTMP/env/lib/python2.7/site-packages/RBTools-0.6.2-py2.7.egg/rbtools/api/request.pyc in process_error(self, http_status, data)
    455 
    456             raise create_api_error(http_status, rsp['err']['code'], rsp,
--> 457                                    rsp['err']['msg'])
    458         except ValueError:
    459             logging.debug('Got HTTP error: %s: %s' % (http_status, data))

BadRequestError: One or more fields had errors (HTTP 400, API Error 105)

    interdiff-revision: Field is not supported



__________________________________________________________________________

This is problem with replacing all "_" by "-" where http url is created (api/request.py line 54)
Place where this argument is defined - reviewboard/webapi/resources/diff_context.py#L43

Best Regards,
Michal
david
#1 david
  • +Project-RBTools
    +Component-RBTools
#2 smacleod
I'd argue that this a Review Board bug, not RBTools. https://www.reviewboard.org/docs/manual/dev/webapi/2.0/resources/diff-context/#webapi2.0-diff-context-resource breaks the convention where all parameters use "-" as a separator instead of "_".

It actually appears like a lot of new API parameters that have been added since the RBTools API bindings were written break the old convention :(

Guess we will need to figure out a fix in RBTools...
#3 smacleod
Actually, scratch that comment about a lot of resources breaking the convention, I was mistaken. We should fix this in Review Board.
david
#4 david
  • +PendingReview
  • -Component-RBTools
    +Component-API
  • +david
david
#5 david
Fixed in release-2.0.x (375d93a). Thanks!
  • -PendingReview
    +Fixed