Repository: buildbot/buildbot

Issue:
Gerrit Change Event Monitor: assertion error: codebase cannot be None
I am getting this stacktrace in the log, with Buildbot 2.6.0 . I do not see this problem with Buildbot 2.5.1 .

2020-02-05 09:11:59-0500 [-] Unhandled Error
        Traceback (most recent call last):
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send(result)
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/buildbot/changes/gerritchangesource.py", line 180, in addChange
            self.master.db.sourcestamps.findOrCreateId(**stampdict))
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/twisted/internet/defer.py", line 1613, in unwindGenerator
            return _cancellableInlineCallbacks(gen)
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
            _inlineCallbacks(None, g, status)
        --- <exception caught here> ---
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/buildbot/changes/gerritchangesource.py", line 343, in outReceived
            yield self.change_source.lineReceived(line)
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/buildbot/changes/gerritchangesource.py", line 253, in addChangeFromEvent
            'properties': properties})
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/buildbot/changes/gerritchangesource.py", line 180, in addChange
            self.master.db.sourcestamps.findOrCreateId(**stampdict))
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send(result)
          File "/home/buildbot/build-venv/lib/python3.6/site-packages/buildbot/db/sourcestamps.py", line 58, in findOrCreateId
            assert codebase is not None, "codebase cannot be None"
        builtins.AssertionError: codebase cannot be None



Discussion:
Potential changes in a98079481870d19edd5eb9b2883db0c1ef6086fe ?
Adding line 177 in buildbot/changes/gerritchangesource.py seems to work around the problem.

168     @defer.inlineCallbacks
169     def addChange(self, chdict):
170         stampdict = {
171             "branch": chdict["branch"],
172             "revision": chdict["revision"],
173             "patch_author": chdict["author"],
174             "patch_comment": chdict["comments"],
175             "repository": chdict["repository"],
176             "project": chdict["project"],
177             "codebase": '',
178         }


Resolving patch:
diff --git a/master/buildbot/changes/gerritchangesource.py b/master/buildbot/changes/gerritchangesource.py
--- a/master/buildbot/changes/gerritchangesource.py
+++ b/master/buildbot/changes/gerritchangesource.py
@@ -171,6 +171,7 @@ def addChange(self, chdict):
             "patch_comment": chdict["comments"],
             "repository": chdict["repository"],
             "project": chdict["project"],
+            "codebase": '',
         }
 
         stampid, found_existing = yield(


Test patch:
diff --git a/master/buildbot/test/fakedb/sourcestamps.py b/master/buildbot/test/fakedb/sourcestamps.py
--- a/master/buildbot/test/fakedb/sourcestamps.py
+++ b/master/buildbot/test/fakedb/sourcestamps.py
@@ -98,6 +98,11 @@ def findOrCreateId(self, branch=None, revision=None, repository=None,
                        patch_body=None, patch_level=None,
                        patch_author=None, patch_comment=None,
                        patch_subdir=None):
+
+        assert codebase is not None, "codebase cannot be None"
+        assert project is not None, "project cannot be None"
+        assert repository is not None, "repository cannot be None"
+
         if patch_body:
             patchid = len(self.patches) + 1
             while patchid in self.patches: