Do not fail if user is missing username attribute

The serviceuser plugin provides a commit validator that checking each
pushed commit, whether the committer is a serviceuser.

If the validation fails the push fails, even if the user is no


  [SSH git-receive-pack xxx] WARN
  MultiProgressMonitor : MultiProgressMonitor worker did not call end()
  before returning
  [SSH git-receive-pack xxx] ERROR
  AsyncReceiveCommits : error while processing push
  java.util.concurrent.ExecutionException: java.util.NoSuchElementException:
  No value present

  Caused by: java.util.NoSuchElementException: No value present
          at java.base/java.util.Optional.get(
          at com.googlesource.gerrit.plugins.serviceuser.GetServiceUser.
          at com.googlesource.gerrit.plugins.serviceuser.ServiceUserResolver.
          at com.googlesource.gerrit.plugins.serviceuser.ValidateServiceUserCommits.

Users without username attribute are valid in case of OAuth and other
providers until user once set them.

This change ignores users that are missing username attribute.

Change-Id: I505edc7689ab0e9bd8adee42508badf9bdcec867
Signed-off-by: Alon Bar-Lev <>
1 file changed