4912: Cleanly handle moved files


What version of Review Board are you running?


What version of Review Bot are you running?


What tool(s) is Review Bot running?


What steps will reproduce the problem?

  1. Move a file in git and post via rbt

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

The code review shows the file was moved. Yet the bot reports an internal error. Below is a worker stack trace. In processing/review.py, it only catches http_status=404 (deleted files), but not http_status=500

File "/usr/local/lib/python3.6/dist-packages/reviewbot/processing/review.py", line 89, in get_patched_file_path
contents = self.patched_file_contents
File "/usr/local/lib/python3.6/dist-packages/reviewbot/processing/review.py", line 60, in patched_file_contents
patched_file = self._api_filediff.get_patched_file()
File "/usr/local/lib/python3.6/dist-packages/rbtools/api/resource.py", line 190, in <lambda>
self._get_url(url, kwargs)))
File "/usr/local/lib/python3.6/dist-packages/rbtools/api/decorators.py", line 27, in request_method
File "/usr/local/lib/python3.6/dist-packages/rbtools/api/transport/sync.py", line 77, in execute_request_method
return self._execute_request(request)
File "/usr/local/lib/python3.6/dist-packages/rbtools/api/transport/sync.py", line 86, in _execute_request
rsp = self.server.make_request(request)
File "/usr/local/lib/python3.6/dist-packages/rbtools/api/request.py", line 687, in make_request
self.process_error(e.code, e.read())
File "/usr/local/lib/python3.6/dist-packages/rbtools/api/request.py", line 661, in process_error
rbtools.api.errors.APIError: There was an error fetching a source file. (HTTP 500, API Error 221)

Please provide any additional information below.

#1 almt

For now, made a small change

--- a/bot/reviewbot/processing/review.py
+++ b/bot/reviewbot/processing/review.py
@@ -91,6 +91,9 @@ class File(object):
                 if e.http_status == 404:
                     # This was a deleted file.
                     return None
+                elif e.http_status == 500:
+                    # This was a removed file.
+                    return None