2333: Unhandled exception when adding a bug tracker ID

ben.*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Oct. 19, 2011
What version are you running?
1.6.1

What's the URL of the page containing the problem?
http://reviews.myserver/r/490/

What steps will reproduce the problem?
1. Create a new review request from the web UI.  Make sure to select "(None - Graphics only)" in the repository drop-down.
2. Fill in something for in the "Summary" and "People" fields, then click "Publish".
3. Edit the review request and add something into the "Bugs" field.  Click "Publish".

What is the expected output? What do you see instead?
After step 2, everything is working as expected.  Immediately after clicking "Publish" in step 3, I am re-directed to an "Error 500" page and I get a server error report emailed to me.  Any attempts to view the review request at this point result in the same error message.

What operating system are you using? What browser?
I am running Firefox 7.0.1 on Windows 7 64-bit, but I have confirmed this on IE7 in Vista as well (although this doesn't seem browser-related).


Please provide any additional information below.
I can recover the review request by using the admin interface to edit the review request in question and changing the "Repository" field to something other than "None".  Simply removing the entry in the "Bugs" field does not resolve this problem.

It appears that ReviewBoard is attempting to turn the bug number into a link, but there is no way to specify a bug tracker URL when "(None - Graphics only)" is chosen as a repository.  When no repository is listed, ReviewBoard should either hide and ignore the "Bugs" field or treat it as a plain-text field and not try to link-ify it.

----
The following information came from the traceback that was auto-emailed to me after I attempted to view the bugged review request:

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.1-py2.7.egg/reviewboard/accounts/decorators.py", line 19, in _check
    return login_required(view_func)(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/Djblets-0.6.11-py2.7.egg/djblets/auth/util.py", line 46, in _checklogin
    return view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-1.6.1-py2.7.egg/reviewboard/reviews/views.py", line 381, in review_detail
    review_request.repository.bug_tracker):

AttributeError: 'NoneType' object has no attribute 'bug_tracker'
#1 ben.*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Looking at the current code on github (c59e9abc0261e19e91e2024f55b964198f1cbbdc), it looks like the problem is in views.py in the 'if' statement beginning on line 383:

 if (name == "bugs_closed" and
     review_request.repository.bug_tracker):

Changing this to something like the following should avoid this exception:

 if (name == "bugs_closed" and
     review_request.repository and
     review_request.repository.bug_tracker):

This may not 100% solve the underlying problem (I haven't tried to build RB from source with this change), but it should at least avoid this particular exception.
david
#2 david
Pushed the fix to release-1.6.x. Thanks!
  • +Fixed