Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GerritEventLogPoller.getFiles has no error handling #7612

Closed
flichtenheld opened this issue May 15, 2024 · 1 comment · Fixed by #7647
Closed

GerritEventLogPoller.getFiles has no error handling #7612

flichtenheld opened this issue May 15, 2024 · 1 comment · Fixed by #7647
Labels

Comments

@flichtenheld
Copy link

If the API call fails, e.g. due to change being deleted, or buildbot not having access to that project, it throws an exception:

2024-05-15 10:12:38+0000 [-] while polling for changes
	Traceback (most recent call last):
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 913, in errback
	    self._startRunCallbacks(fail)
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 981, in _startRunCallbacks
	    self._runCallbacks()
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1075, in _runCallbacks
	    current.result = callback(  # type: ignore[misc]
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1946, in _gotResultInlineCallbacks
	    _inlineCallbacks(r, gen, status, context)
	--- <exception caught here> ---
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1996, in _inlineCallbacks
	    result = context.run(
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/python/failure.py", line 519, in throwExceptionIntoGenerator
	    return g.throw(self.type, self.value, self.tb)
	  File "/buildbot_venv/lib/python3.9/site-packages/buildbot/changes/gerritchangesource.py", line 566, in poll
	    yield self.lineReceived(line)
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1996, in _inlineCallbacks
	    result = context.run(
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/python/failure.py", line 519, in throwExceptionIntoGenerator
	    return g.throw(self.type, self.value, self.tb)
	  File "/buildbot_venv/lib/python3.9/site-packages/buildbot/changes/gerritchangesource.py", line 570, in eventReceived
	    res = yield super().eventReceived(event)
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 1996, in _inlineCallbacks
	    result = context.run(
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/python/failure.py", line 519, in throwExceptionIntoGenerator
	    return g.throw(self.type, self.value, self.tb)
	  File "/buildbot_venv/lib/python3.9/site-packages/buildbot/changes/gerritchangesource.py", line 254, in addChangeFromEvent
	    files = yield self.getFiles(
	  File "/buildbot_venv/lib/python3.9/site-packages/twisted/internet/defer.py", line 2000, in _inlineCallbacks
	    result = context.run(gen.send, result)
	  File "/buildbot_venv/lib/python3.9/site-packages/buildbot/changes/gerritchangesource.py", line 580, in getFiles
	    res = res.splitlines()[1].decode('utf8')  # the first line of every response is `)]}'`
	builtins.IndexError: list index out of range

This causes buildbot to loop over the event log again and again, with no easy way to get out of it except to disable get_files (and whatever code needed that information).

When looking at the code the problem is obvious:

@defer.inlineCallbacks
    def getFiles(self, change, patchset):
        res = yield self._http.get(f"/changes/{change}/revisions/{patchset}/files/")
        res = yield res.content()

        res = res.splitlines()[1].decode('utf8')  # the first line of every response is `)]}'`
        return list(json.loads(res))

Probably should return gracefully ("unknown") when res is shorter than 2 lines.

@mokibit
Copy link
Collaborator

mokibit commented May 20, 2024

Hi, @flichtenheld,
Thanks for opening the issue.
It has been fixed in PR #7647.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants