3473: Browsing to /reviews/r/<id>/diff/<rev>/fragment/<random number> causes Internal Server Error

erik*****@gmai***** (Google Code) (Is this you? Claim this profile.)
July 9, 2014
What version are you running?
2.0.2

What's the URL of the page containing the problem?
 /reviews/r/<id>/diff/<rev>/fragment/<random number>

What steps will reproduce the problem?
1. Create a review with attached diff and publish it.
2. Browse to aforementioned address.

What is the expected output? What do you see instead?
I would expected to see the typical 404 page. Instead the server generates an internal error and I see the following in the logs:

Traceback (most recent call last):

 File "/usr/local/lib/python2.7/dist-packages/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 "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/views/generic/base.py", line 69, in view
   return self.dispatch(request, *args, **kwargs)

 File "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/utils/decorators.py", line 29, in _wrapper
   return bound_func(*args, **kwargs)

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

 File "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/contrib/auth/decorators.py", line 22, in _wrapped_view
   return view_func(request, *args, **kwargs)

 File "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/utils/decorators.py", line 25, in bound_func
   return func(self, *args2, **kwargs2)

 File "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/utils/decorators.py", line 29, in _wrapper
   return bound_func(*args, **kwargs)

 File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-2.0.2-py2.7.egg/reviewboard/site/decorators.py", line 35, in _check
   return view_func(request, local_site=local_site, *args, **kwargs)

 File "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/utils/decorators.py", line 25, in bound_func
   return func(self, *args2, **kwargs2)

 File "/usr/local/lib/python2.7/dist-packages/Djblets-0.8.5-py2.7.egg/djblets/util/decorators.py", line 78, in _call
   f = augmented_func(*args, **kwargs)

 File "/usr/local/lib/python2.7/dist-packages/Django-1.6.5-py2.7.egg/django/views/generic/base.py", line 87, in dispatch
   return handler(request, *args, **kwargs)

 File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-2.0.2-py2.7.egg/reviewboard/reviews/views.py", line 1102, in get
   chunkindex=chunkindex)

 File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-2.0.2-py2.7.egg/reviewboard/diffviewer/views.py", line 243, in get
   'file': self._get_requested_diff_file(False),

 File "/usr/local/lib/python2.7/dist-packages/ReviewBoard-2.0.2-py2.7.egg/reviewboard/diffviewer/views.py", line 362, in _get_requested_diff_file
   files = get_diff_files(self.diffset, self.filediff, self.interdiffset,

AttributeError: 'ReviewsDiffFragmentView' object has no attribute 'filediff'


What operating system are you using? What browser?
The server is running on Ubuntu 12.04. Browser is Safari OS X 10.9

Please provide any additional information below.
It appears that the exception handler in DiffFragmentView.get() doesn't deal with the case where self.create_renderer() throws before it has a chance to set self.filediff. In fact there are two places where a Http404 error can be raised before the setting of self.filediff in create_renderer(). I believe the exception handler is just too broad and an explicit catch of Http404 errors should be added which just re-raises the error so it can be handled by the default view.

(Now the next question is why are users trying to hit this URL. After initial discussions it appears they are just performing 'rbt post' using Perforce change lists with RBTools 0.6 but I've yet to be able to reproduce the problem so I will leave that to another bug report when I have more information).
#1 erik*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Adding simple patch.
david
#2 david
Please post patches on https://reviews.reviewboard.org/
#3 erik*****@gmai***** (Google Code) (Is this you? Claim this profile.)
Good point. I'll post something shortly.
david
#4 david
Fixed in release-2.0.x (927c345). Thanks!
  • +Fixed