3508: Post Reivew allows you to update a review request draft to a commit ID that is already present in another review.

thom.******@gmai***** (Google Code) (Is this you? Claim this profile.)
Aug. 25, 2014
What version are you running?

Triggered the exception on https://reviews.reviewboard.org/ at sometime around July 30, 2014 1:30 PM PT .  

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


What steps will reproduce the problem?
1. Create a review request (# 6168) for commit 09263fedc72b1dd34b7ce11d7e9238664d3316ed .  It need not be published.
2. Create a review request (# 6169) for commit 9419d95630f1d455ceaf8932fdf793faee03543b . 
3. Update the second review request with the same SHA as the first `rbt post -r6169 09263fedc72b1dd34b7ce11d7e9238664d3316ed`
   -  This should get rejected because a review request exists already for this ID but it is not currently.
4. Attempt to publish Request #6169 from the web ui or rbt post -p
   - Trigger 500 error for Integrity Error.

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

Step #3 should not be be possible.  Step #4 should give a better error message if you get to this state somehow.

What operating system are you using? What browser?

Chrome, Firefox, rbt post on linux.

Please provide any additional information below.

Stack trace of the Integrity Error from a Reviewboard 2.0.3 server:

Traceback (most recent call last):

  File "Django-1.6.5-py2.7.egg/django/core/handlers/base.py", line 112, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File "Django-1.6.5-py2.7.egg/django/views/decorators/cache.py", line 52, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "Django-1.6.5-py2.7.egg/django/views/decorators/vary.py", line 19, in inner_func
    response = func(*args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/resources.py", line 494, in __call__
    request, method, view, api_format=api_format, *args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/resources.py", line 565, in call_method_view
    return view(request, *args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/resources.py", line 753, in put
    return self.update(request, *args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)

  File "ReviewBoard-2.0.3-py2.7.egg/reviewboard/webapi/decorators.py", line 110, in _check
    return view_func(*args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/decorators.py", line 138, in _checklogin
    return view_func(*args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)

  File "Djblets-0.8.6-py2.7.egg/djblets/webapi/decorators.py", line 287, in _validate
    return view_func(*args, **new_kwargs)

  File "ReviewBoard-2.0.3-py2.7.egg/reviewboard/webapi/resources/review_request_draft.py", line 394, in update

  File "ReviewBoard-2.0.3-py2.7.egg/reviewboard/reviews/models/review_request.py", line 716, in publish
    changes = draft.publish(self, send_notification=False)

  File "ReviewBoard-2.0.3-py2.7.egg/reviewboard/reviews/models/review_request_draft.py", line 318, in publish

  File "ReviewBoard-2.0.3-py2.7.egg/reviewboard/reviews/models/review_request.py", line 581, in save
    super(ReviewRequest, self).save(**kwargs)

  File "ReviewBoard-2.0.3-py2.7.egg/reviewboard/reviews/models/base_review_request_details.py", line 258, in save
    super(BaseReviewRequestDetails, self).save(**kwargs)

  File "Django-1.6.5-py2.7.egg/django/db/models/base.py", line 545, in save
    force_update=force_update, update_fields=update_fields)

  File "Django-1.6.5-py2.7.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 "Django-1.6.5-py2.7.egg/django/db/models/base.py", line 635, in _save_table

  File "Django-1.6.5-py2.7.egg/django/db/models/base.py", line 679, in _do_update
    return filtered._update(values) > 0

  File "Django-1.6.5-py2.7.egg/django/db/models/query.py", line 510, in _update
    return query.get_compiler(self.db).execute_sql(None)

  File "Django-1.6.5-py2.7.egg/django/db/models/sql/compiler.py", line 980, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)

  File "Django-1.6.5-py2.7.egg/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)

  File "Django-1.6.5-py2.7.egg/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)

  File "Django-1.6.5-py2.7.egg/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)

  File "Django-1.6.5-py2.7.egg/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)

  File "Django-1.6.5-py2.7.egg/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)

  File "MySQL_python-1.2.5-py2.7-linux-i686.egg/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)

  File "MySQL_python-1.2.5-py2.7-linux-i686.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue

IntegrityError: (1062, "Duplicate entry '49023f413fc1c59fc04e0e78eadc8f935c1c3bbc-245' for key 'reviews_reviewrequest_b8c24015'")
#1 chipx86
  • +PendingReview
  • -Priority-Medium
  • +chipx86
#2 chipx86
Fixed on release-2.0.x (249a691)
  • -PendingReview