4009: branch value gets null when using the api to create a review

hanabishi

If we don't send the branch variable to /api/review-requests/ when creating a request we get a nullpointer on the server. Looks like the branch variable will be null on the server side and then RB tries to save this into the database (that has the field set to not null).
The same scripts we used worked before we upgraded to 2.5.1 from 2.0

If I change the script to also submitt the branch variable then the api works.

What version are you running?

2.5.1

What's the URL of the page containing the problem?

/api/review-requests/

What steps will reproduce the problem?

do a post to /api/review-requests/ without sending the branch in the request data

What is the expected output? What do you see instead?

exptected an OK from the rest call but gets a stacktrace

What operating system are you using? What browser?

Ubuntu

Please provide any additional information below.

Traceback (most recent call last):

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, callback_args, *callback_kwargs)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/views/decorators/vary.py", line 19, in inner_func
response = func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/resources/base.py", line 195, in call
request, method, view, api_format=api_format, args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/resources/mixins/api_tokens.py", line 65, in call_method_view
return view(request, args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/resources/base.py", line 448, in post
return self.create(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/decorators.py", line 120, in _call
return view_func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-2.5.1-py2.6.egg/reviewboard/webapi/decorators.py", line 125, in _check
return view_func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/decorators.py", line 120, in _call
return view_func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/decorators.py", line 141, in _checklogin
return view_func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/decorators.py", line 120, in _call
return view_func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/decorators.py", line 120, in _call
return view_func(args, *kwargs)

File "/usr/local/lib/python2.6/dist-packages/Djblets-0.9-py2.6.egg/djblets/webapi/decorators.py", line 301, in _validate
return view_func(args, *new_kwargs)

File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-2.5.1-py2.6.egg/reviewboard/webapi/resources/review_request.py", line 661, in create
create_from_commit_id=create_from_commit_id)

File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-2.5.1-py2.6.egg/reviewboard/reviews/managers.py", line 161, in create
review_request.save()

File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-2.5.1-py2.6.egg/reviewboard/reviews/models/review_request.py", line 660, in save
super(ReviewRequest, self).save(**kwargs)

File "/usr/local/lib/python2.6/dist-packages/ReviewBoard-2.5.1-py2.6.egg/reviewboard/reviews/models/base_review_request_details.py", line 289, in save
super(BaseReviewRequestDetails, self).save(**kwargs)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/base.py", line 545, in save
force_update=force_update, update_fields=update_fields)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/base.py", line 573, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/base.py", line 654, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/base.py", line 687, in _do_insert
using=using, raw=raw)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/manager.py", line 232, in _insert
return insert_query(self.model, objs, fields, **kwargs)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/query.py", line 1514, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/models/sql/compiler.py", line 903, in execute_sql
cursor.execute(sql, params)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/backends/util.py", line 53, in execute
return self.cursor.execute(sql, params)

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/backends/mysql/base.py", line 129, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])

File "/usr/local/lib/python2.6/dist-packages/Django-1.6.11-py2.6.egg/django/db/backends/mysql/base.py", line 124, in execute
return self.cursor.execute(query, args)

File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in execute
self.errorhandler(self, exc, value)

File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue

IntegrityError: (1048, "Column 'branch' cannot be null")

<WSGIRequest
path:/api/review-requests/,
GET:<QueryDict: {}>,
POST:<QueryDict: {u'repository': [u'8']}>, COOKIES:{},
META:{'CONTENT_LENGTH': '12',
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
u'CSRF_COOKIE': u'<REMOVED>',
u'CSRF_COOKIE_USED': True,
'DOCUMENT_ROOT': '<REMOVED>',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': '/',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate, compress',
'HTTP_AUTHORIZATION': 'Basic <REMOVED>',
'HTTP_HOST': <REMOVED>,
'HTTP_USER_AGENT': 'python-requests/2.2.1 CPython/3.4.1 Windows/7',
u'LOCAL_SITE': None,
'PATH_INFO': u'/api/review-requests/',
'PATH_TRANSLATED': <REMOVED>,
'QUERY_STRING': '',
'REMOTE_ADDR': '<REMOVED>',
'REMOTE_PORT': '56497',
'REQUEST_METHOD': 'POST',
'REQUEST_URI': '/api/review-requests/',
'SCRIPT_FILENAME': '<REMOVED>/htdocs/reviewboard.wsgi',
'SCRIPT_NAME': u'',
'SERVER_ADDR': '<REMOVED>',
'SERVER_ADMIN': '[no address given]',
'SERVER_NAME': '<REMOVED>',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.16 (Ubuntu) Server at <REMOVED> Port 80</address>\n',
'SERVER_SOFTWARE': 'Apache/2.2.16 (Ubuntu)',
u'USERNAME': u'<REMOVED>',
u'USER_EMAIL': u'<REMOVED>',
'mod_wsgi.application_group': '<REMOVED>|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80',
'mod_wsgi.process_group': '',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 2),
'wsgi.errors': <mod_wsgi.Log object at 0x7f5b8256af70>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f5b81ef3dc8>,
'wsgi.input': <mod_wsgi.Input object at 0x7f5b81ef9130>,
'wsgi.multiprocess': True,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 1)}>

#1 hanabishi

A patch has been sent https://github.com/reviewboard/reviewboard/pull/38

chipx86
#2 chipx86

We've reverted the change for this and released 2.5.1.1. We'll try to get this re-introduced properly, with proper testing.

#3 hanabishi

I love the response time on this issue, it's times like these that I'm glad we run Review Board :)

david
#4 david
  • -New
    +Fixed