Repository: buildbot/buildbot

Issue:
hgpoller fails with "null value in column committer"
I'm running a Buildbot master inside a Docker container, and I have an HgPoller set up to poll a Kallithea repository. When the poller detects changes, it fails with the following:

```
buildbot_1  | 2019-08-23 19:58:52+0000 [-] hgpoller: repo poll failed
{... unneeded stack trace ...}
buildbot_1  |   sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "committer" violates not-null constraint
buildbot_1  |   DETAIL:  Failing row contains (9, marisa <marisa@mokou.zone>, null, Add lint script for CI execution, default, 8c43f72068449130372da25f6583531c9e4f88a8, , 1566588893, null, https://callie.marisa.cloud/tometo/tometo, , tometo, 1, null).
```

Reading through the hgpoller source, this seems to stem from here:

https://github.com/buildbot/buildbot/blob/master/master/buildbot/changes/hgpoller.py#L285

Am I correct in assuming that `committer=None` is directly opposed to `committer` being a non-null constraint in the database? If so, wouldn't that be a clear bug?


Discussion:
@komaeda Yes I think you're right. Since there's no concept of `committer` in mercurial, we can either set it to an empty string in hgpoller or set it as nullable in the db layer.
committer and author should be identical, if there is no notion of committer
@tardyp So just set `committer` to `author` unconditionally? Mind if I create a pull request for that?
pull requests are always very much welcomed
Pierre


Le lun. 26 août 2019 à 13:17, eev <notifications@github.com> a écrit :

> @tardyp <https://github.com/tardyp> So just set committer to author
> unconditionally? Mind if I create a pull request for that?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/buildbot/buildbot/issues/4987?email_source=notifications&email_token=AAA22I4HWXEKN6WAZCVQ6STQGO3SZA5CNFSM4IPC367KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5ECFWY#issuecomment-524821211>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAA22I7BJISXVWQUFMMM77LQGO3SZANCNFSM4IPC367A>
> .
>

> @tardyp So just set `committer` to `author` unconditionally? Mind if I create a pull request for that?

Yes, but only for the version control systems which don't support the committer. Subversion and mercurial come to mind, and you should not do it for git. I'm not familiar with the rest.
I had accidentally set all of them except git (svn, hg, etc.) to none. Bitbucket needs to be fixed as well https://github.com/buildbot/buildbot/blob/master/master/buildbot/changes/bitbucket.py#L144
are we saying that all changesources but git are broken in buildbot 2.4?
@tardyp: after a second thought: is it really necessary that the committer field is not null / equal to the author?

From my point of view it could be handled both ways (either being null or equal to the author for the systems that don't support this). Unless the committer would be actually used in some ways where it's always needed, I find it perfectly OK (actually better) if we have some values set to null when the underlying version control system doesn't support that particular variable, and just change the database entry to allow nulls.

As an extreme example, I was thinking of potentially writing `RsyncPoller` which would check whether anything changed on the rsync server. This could work perfectly well to trigger the builds only when changes are seen, but the only reasonable value for the author (and committer) would in fact be null.

So in a way I would be more in favour of properly supporting null values, but it's of course up to you to decide.
> are we saying that all changesources but git are broken in buildbot 2.4?

Yes, I guess (I hadn't manually tested on other vcs)
@mojca the reason I set it to not null was because it would otherwise become difficult to handle situations where committer can't be null (say in git).
But your argument is also perfectly valid. So it's up to @tardyp 

Resolving patch:
diff --git a/master/buildbot/db/model.py b/master/buildbot/db/model.py
--- a/master/buildbot/db/model.py
+++ b/master/buildbot/db/model.py
@@ -370,7 +370,7 @@ class Model(base.DBConnectorComponent):
         sa.Column('author', sa.String(255), nullable=False),
 
         # committer's name
-        sa.Column('committer', sa.String(255), nullable=False),
+        sa.Column('committer', sa.String(255), nullable=True),
 
         # commit comment
         sa.Column('comments', sa.Text, nullable=False),


Test patch: