Skip to content

backport: Fix bad behavior if nonexistent change number is supplied

Before:
debian@deploy:~$ scap backport 0
17:08:34 Status: 404
17:08:34 Not found: 0

17:08:34 Unhandled error:
Traceback (most recent call last):
File "/workspace/scap/scap/cli.py", line 552, in run
exit_status = app.main(app.extra_arguments)
File "/workspace/scap/scap/plugins/backport.py", line 323, in main
self.backports = GerritChanges(self.get_logger(), self.gerrit, change_numbers)
File "/workspace/scap/scap/plugins/backport.py", line 174, in init
change_numbers,
File "/workspace/scap/scap/plugins/backport.py", line 173, in
lambda number: (number, GerritChange(gerrit, number)),
File "/workspace/scap/scap/plugins/backport.py", line 202, in init
self.update_details()
File "/workspace/scap/scap/plugins/backport.py", line 216, in update_details
self.details = self.gerrit.change_detail(self.number).get()
File "/workspace/scap/scap/plugins/gerrit.py", line 183, in get
return self.load(res)
File "/workspace/scap/scap/plugins/gerrit.py", line 201, in load
"Request Failed: %s %s %s" % (res.url, res.status_code, res.text)
Exception: Request Failed: http://gerrit.traindev:8080/changes/0/detail?o=COMMIT_FOOTERS&o=CURRENT_REVISION 404 Not found: 0

17:08:34 backport failed: Request Failed: http://gerrit.traindev:8080/changes/0/detail?o=COMMIT_FOOTERS&o=CURRENT_REVISION 404 Not found: 0

After:
debian@deploy:~$ scap backport 0
Change '0' not found

Bug: T362927

Merge request reports