3701: 500 error when publishing if user has opted out of own activity notifications

nex****@gmai***** (Google Code) (Is this you? Claim this profile.)
Dec. 19, 2014
What version are you running?
2.0.11

What's the URL of the page containing the problem?
"PUT /api/review-requests/4992/draft/

What steps will reproduce the problem?
1. Unsubscribe from all notification emails (own activity and review requests and reviews)
2. Publish something (comment, review request etc)
3. Error 500 returned, though the publish was actually successfuly.

What is the expected output? What do you see instead?
Status 200 OK

What operating system are you using? What browser?
"Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"

Please provide any additional information below.

Username replaced with [USER]
Email replaced with [EMAIL]

/var/log/httpd/access_log

10.0.1.49 - - [19/Dec/2014:14:59:37 +0000] "PUT /api/review-
requests/4992/draft/ HTTP/1.1" 500 250 "http://reviewboard.xxxxxxx.com/r/4992/" "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"

reviewboard.log:

2014-12-19 14:59:37,377 - ERROR -  - Exception thrown for user [USER] at http://reviewboard.xxxxxxx.com/api/review-requests/4992/draft/

u'"[USER]" <[EMAIL]>'
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/Django-1.6.8-py2.6.egg/django/core/handlers/base.py", line 112, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.6/site-packages/Django-1.6.8-py2.6.egg/django/views/decorators/cache.py", line 52, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Django-1.6.8-py2.6.egg/django/views/decorators/vary.py", line 19, in inner_func
    response = func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/resources.py", line 496, in __call__
    request, method, view, api_format=api_format, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/resources.py", line 567, in call_method_view
    return view(request, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/resources.py", line 764, in put
    return self.update(request, *args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.11-py2.6.egg/reviewboard/webapi/decorators.py", line 110, in _check
    return view_func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/decorators.py", line 138, in _checklogin
    return view_func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/decorators.py", line 117, in _call
    return view_func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/Djblets-0.8.13-py2.6.egg/djblets/webapi/decorators.py", line 287, in _validate
    return view_func(*args, **new_kwargs)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.11-py2.6.egg/reviewboard/webapi/resources/review_request_draft.py", line 439, in update
    review_request.publish(user=request.user)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.11-py2.6.egg/reviewboard/reviews/models/review_request.py", line 792, in publish
    changedesc=changes)
  File "/usr/lib/python2.6/site-packages/Django-1.6.8-py2.6.egg/django/dispatch/dispatcher.py", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.11-py2.6.egg/reviewboard/notifications/email.py", line 46, in review_request_published_cb
    mail_review_request(review_request, changedesc)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.11-py2.6.egg/reviewboard/notifications/email.py", line 347, in mail_review_request
    extra_context)
  File "/usr/lib/python2.6/site-packages/ReviewBoard-2.0.11-py2.6.egg/reviewboard/notifications/email.py", line 227, in send_review_mail
    recipients.remove(from_email)
KeyError: u'"[USER]" <[EMAIL]>'

The exception is thrown at /reviewboard/notifications/email.py line 227: 

  if not user.should_send_own_updates():
        recipients.remove(from_email)

I changed the code to the following and this fixes the issue:

   if not user.should_send_own_updates() and from_email in recipients:
        recipients.remove(from_email)
david
#1 david
This has already been fixed in git and will ship with 2.0.12. Thanks.
  • +Fixed