1847: The diff-comments resource is unaccessible in REST API 2.0

dek****@gmai***** (Google Code) (Is this you? Claim this profile.)
June 17, 2011
What version are you running?
1.5

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

What steps will reproduce the problem?
1. Attempt a GET of a diff-comments resource URL in the REST API

What is the expected output? What do you see instead?
Expect return of JSON resource. G
et a 500 status code and the following traceback:
---------------------------------------------------------------------------
Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/core/handlers/base.py", line 92, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/views/decorators/vary.py", line 21, in inner_func
    response = func(*args, **kwargs)

  File "/usr/lib/python2.5/site-packages/Djblets-0.6.5alpha0.dev_20101008-py2.5.egg/djblets/webapi/resources.py", line 284, in __call__
    result = view(request, api_format=api_format, *args, **kwargs)

  File "/usr/lib/python2.5/site-packages/Djblets-0.6.5alpha0.dev_20101008-py2.5.egg/djblets/util/decorators.py", line 74, in _call
    f = real_func(*args, **kwargs)

  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.5-py2.5.egg/reviewboard/webapi/decorators.py", line 25, in _check
    return view_func(*args, **kwargs)

  File "/usr/lib/python2.5/site-packages/Djblets-0.6.5alpha0.dev_20101008-py2.5.egg/djblets/webapi/decorators.py", line 233, in _validate
    return view_func(*args, **new_kwargs)

  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.5-py2.5.egg/reviewboard/webapi/resources.py", line 103, in get_list
    return self._get_list_impl(request, *args, **kwargs)

  File "/usr/lib/python2.5/site-packages/ReviewBoard-1.5-py2.5.egg/reviewboard/webapi/resources.py", line 112, in _get_list_impl
    return super(WebAPIResource, self).get_list(request, *args, **kwargs)

  File "/usr/lib/python2.5/site-packages/Djblets-0.6.5alpha0.dev_20101008-py2.5.egg/djblets/webapi/decorators.py", line 233, in _validate
    return view_func(*args, **new_kwargs)

  File "/usr/lib/python2.5/site-packages/Djblets-0.6.5alpha0.dev_20101008-py2.5.egg/djblets/webapi/resources.py", line 469, in get_list
    extra_data=data)

  File "/usr/lib/python2.5/site-packages/Djblets-0.6.5alpha0.dev_20101008-py2.5.egg/djblets/webapi/core.py", line 322, in __init__
    results = list(results)

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/db/models/query.py", line 83, in __len__
    self._result_cache.extend(list(self._iter))

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/db/models/query.py", line 238, in iterator
    for row in self.query.results_iter():

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/db/models/sql/query.py", line 287, in results_iter
    for rows in self.execute_sql(MULTI):

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/db/models/sql/query.py", line 2369, in execute_sql
    cursor.execute(sql, params)

  File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/db/backends/sqlite3/base.py", line 193, in execute
    return Database.Cursor.execute(self, query, params)

InterfaceError: Error binding parameter 1 - probably unsupported type.


<ModPythonRequest
path:/api/review-requests/477/reviews/1282/diff-comments/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'AUTH_TYPE': None,
 'CONTENT_LENGTH': 0,
 'CONTENT_TYPE': None,
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_HOST': 'review.example.com',
 'HTTP_USER_AGENT': 'Python-urllib/1.17',
 'PATH_INFO': u'/api/review-requests/477/reviews/1282/diff-comments/',
 'PATH_TRANSLATED': None,
 'QUERY_STRING': None,
 'REMOTE_ADDR': '172.16.71.82',
 'REMOTE_HOST': None,
 'REMOTE_IDENT': None,
 'REMOTE_USER': None,
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'review.example.com',
 'SERVER_PORT': 80,
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SOFTWARE': 'mod_python'}>
---------------------------------------------------------------------------

What operating system are you using? What browser?
Fedora
No browser (a Python application)
david
#1 david
  • +Component-API
chipx86
#2 chipx86
Not sure where the original bug is, but this has since been fixed.
  • +Fixed
#3 kent****@gmai***** (Google Code) (Is this you? Claim this profile.)
I still have a similar problem with RB 1.6.1 running on Windows. Below is the error info. The code I am using is essentially this:
url = u'http://myreviewboard.net/api/review-requests/1140/reviews/1445/diff-comments/'
headers = { 'Accept' : 'application/json' }
auth = ('user', 'pass')
import requests # http://pypi.python.org/pypi/requests/0.5.1
resp = requests.get(url, headers=headers, auth=auth)
resp.status_code
==> 500


Traceback (most recent call last):

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\core\handlers\base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\views\decorators\cache.py", line 79, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\views\decorators\vary.py", line 22, in inner_func
    response = func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\webapi\resources.py", line 338, in __call__
    result = view(request, api_format=api_format, *args, **kwargs)

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\decorators.py", line 127, in _check
    return view_func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\util\decorators.py", line 75, in _call
    f = augmented_func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\decorators.py", line 127, in _check
    return view_func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\webapi\decorators.py", line 231, in _validate
    return view_func(*args, **new_kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\util\decorators.py", line 75, in _call
    f = augmented_func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\decorators.py", line 32, in _check
    return view_func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\webapi\decorators.py", line 231, in _validate
    return view_func(*args, **new_kwargs)

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\resources.py", line 148, in get_list
    return self._get_list_impl(request, *args, **kwargs)

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\resources.py", line 157, in _get_list_impl
    return super(WebAPIResource, self).get_list(request, *args, **kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\webapi\decorators.py", line 231, in _validate
    return view_func(*args, **new_kwargs)

  File "C:\Python27\lib\site-packages\djblets-0.6.13-py2.7.egg\djblets\webapi\resources.py", line 566, in get_list
    *args, **kwargs).select_related(),

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\resources.py", line 433, in get_queryset
    request, review_request_id, *args, **kwargs)

  File "C:\Python27\lib\site-packages\reviewboard-1.6.1-py2.7.egg\reviewboard\webapi\resources.py", line 323, in get_queryset
    filediff__diffset__history__review_request=review_request)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\manager.py", line 141, in filter
    return self.get_query_set().filter(*args, **kwargs)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\query.py", line 550, in filter
    return self._filter_or_exclude(False, *args, **kwargs)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\query.py", line 568, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\sql\query.py", line 1191, in add_q
    self.add_q(child, used_aliases, force_having=force_having)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\sql\query.py", line 1194, in add_q
    can_reuse=used_aliases, force_having=force_having)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\sql\query.py", line 1129, in add_filter
    connector)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\sql\where.py", line 67, in add
    value = obj.prepare(lookup_type, value)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\sql\where.py", line 316, in prepare
    return self.field.get_prep_lookup(lookup_type, value)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\fields\related.py", line 136, in get_prep_lookup
    return self._pk_trace(value, 'get_prep_lookup', lookup_type)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\fields\related.py", line 209, in _pk_trace
    v = getattr(field, prep_func)(lookup_type, v, **kwargs)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\fields\__init__.py", line 292, in get_prep_lookup
    return self.get_prep_value(value)

  File "C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\db\models\fields\__init__.py", line 479, in get_prep_value
    return int(value)

TypeError: int() argument must be a string or a number, not 'AnonymousUser'


<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe',
 'DOCUMENT_ROOT': 'C:/reviewboard/htdocs',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'application/json',
 'HTTP_ACCEPT_ENCODING': 'gzip',
 'HTTP_CONNECTION': 'close',
 'HTTP_HOST': 'reviewboard.caliperls.net',
 'HTTP_USER_AGENT': 'python-requests.org',
 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH',
 'PATH_INFO': u'/api/review-requests/1140/reviews/1445/diff-comments/',
 'PATH_TRANSLATED': 'C:\\reviewboard\\htdocs\\reviewboard.wsgi\\api\\review-requests\\1140\\reviews\\1445\\diff-comments\\',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '172.18.2.2',
 'REMOTE_PORT': '59982',
 'REQUEST_METHOD': 'GET',
 'REQUEST_URI': '/api/review-requests/1140/reviews/1445/diff-comments/',
 'SCRIPT_FILENAME': 'C:/reviewboard/htdocs/reviewboard.wsgi',
 'SCRIPT_NAME': u'',
 'SERVER_ADDR': '172.16.12.1',
 'SERVER_ADMIN': 'kent.johnson@caliperls.com',
 'SERVER_NAME': 'reviewboard.caliperls.net',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SIGNATURE': '',
 'SERVER_SOFTWARE': 'Apache/2.2.17 (Win32) mod_wsgi/3.3 Python/2.7.1',
 'SystemRoot': 'C:\\WINDOWS',
 'WINDIR': 'C:\\WINDOWS',
 'mod_wsgi.application_group': 'reviewboard.caliperls.net|',
 'mod_wsgi.callable_object': 'application',
 'mod_wsgi.handler_script': '',
 'mod_wsgi.input_chunked': '0',
 'mod_wsgi.process_group': '',
 'mod_wsgi.request_handler': 'wsgi-script',
 'mod_wsgi.script_reloading': '1',
 'mod_wsgi.version': (3, 3),
 'wsgi.errors': <mod_wsgi.Log object at 0x03179B60>,
 'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x0314C1D0>,
 'wsgi.input': <mod_wsgi.Input object at 0x03179DE0>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': True,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 1)}>
#4 dren*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Same comment at kent3, this is still broken in 1.6.1.
I'm getting a similar traceback ending in..

  File "/usr/lib/python2.4/site-packages/Django-1.3.1-py2.4.egg/django/db/models/fields/__init__.py", line 479, in get_prep_value
    return int(value)
TypeError: int() argument must be a string or a number
#5 dren*****@gmai***** (Google Code) (Is this you? Claim this profile.)
ok I found the difference.. this only breaks when accessing the API as an *anonymous* user. Things work fine when the user is authenticated.