Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71955

GitLab branch source scan fails with null pointer exception if credentials are not provided

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major

      A GitLab branch source project fails its initial scan with a null pointer exception. The message is:

      Checking project markewaite-jenkins-plugins/tasks-pipeline
      Proposing markewaite-jenkins-plugins/tasks-pipeline
      ERROR: Failed to create or update a subproject markewaite-jenkins-plugins/tasks-pipeline
      java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because the return value of "org.gitlab4j.api.models.Project.getMergeRequestsEnabled()" is null
      	at io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.retrieve(GitLabSCMSource.java:334)
      	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:372)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:326)
      	at jenkins.branch.MultiBranchProjectFactory$BySCMSourceCriteria.recognizes(MultiBranchProjectFactory.java:262)
      	at jenkins.branch.OrganizationFolder$SCMSourceObserverImpl$1.recognizes(OrganizationFolder.java:1361)
      	at jenkins.branch.OrganizationFolder$SCMSourceObserverImpl$1.complete(OrganizationFolder.java:1376)
      	at jenkins.scm.api.trait.SCMNavigatorRequest.process(SCMNavigatorRequest.java:252)
      	at jenkins.scm.api.trait.SCMNavigatorRequest.process(SCMNavigatorRequest.java:202)
      	at io.jenkins.plugins.gitlabbranchsource.GitLabSCMNavigator.visitSources(GitLabSCMNavigator.java:305)
      	at jenkins.branch.OrganizationFolder.computeChildren(OrganizationFolder.java:535)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:269)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:167)
      	at jenkins.branch.OrganizationFolder$OrganizationScan.run(OrganizationFolder.java:920)
      	at hudson.model.ResourceController.execute(ResourceController.java:101)
      	at hudson.model.Executor.run(Executor.java:442)
      

      The job definition is available as job-definition.xml

          [JENKINS-71955] GitLab branch source scan fails with null pointer exception if credentials are not provided

          Mark Waite created issue -

          Mark Waite added a comment -

          Same failure is also visible on a similarly configured Jenkins 2.414.1 with Java 11.0.20.

          Jenkins: 2.414.1
          OS: Linux - 6.2.0-26-generic
          Java: 11.0.20 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
          

          Mark Waite added a comment - Same failure is also visible on a similarly configured Jenkins 2.414.1 with Java 11.0.20. Jenkins: 2.414.1 OS: Linux - 6.2.0-26-generic Java: 11.0.20 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
          Mark Waite made changes -
          Assignee Original: Parichay Barpanda [ baymac ]

          markewaite I have been able to reproduce this but only without using a proper token to access the gitlab api in my gitlab server configuration. Also I noticed several 401 errors on my log when I was able to reproduce the error. The issue was removed once I added a valid token to my gitlab server conf.

          Also there are tests in https://github.com/jenkinsci/acceptance-test-harness/blob/master/src/test/java/plugins/GitLabPluginTest.java that check you can create a org and a multibranch pipeline without issues.

          Can you please check in your logs for 401 errors? Or check the token you use in your gitlab server conf to see if that is the cause of the issue?

          Raul Arabaolaza added a comment - markewaite I have been able to reproduce this but only without using a proper token to access the gitlab api in my gitlab server configuration. Also I noticed several 401 errors on my log when I was able to reproduce the error. The issue was removed once I added a valid token to my gitlab server conf. Also there are tests in https://github.com/jenkinsci/acceptance-test-harness/blob/master/src/test/java/plugins/GitLabPluginTest.java that check you can create a org and a multibranch pipeline without issues. Can you please check in your logs for 401 errors? Or check the token you use in your gitlab server conf to see if that is the cause of the issue?
          Raul Arabaolaza made changes -
          Assignee New: Raul Arabaolaza [ rarabaolaza ]
          Raul Arabaolaza made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Mark Waite added a comment - - edited

          rarabaolaza I had missed that my authentication token was null for the GitLab server that I had configured. I see the NPE when the authentication token is not defined. The scan works as expected when I use a valid authentication token. Thanks for the investigation!

          Mark Waite added a comment - - edited rarabaolaza I had missed that my authentication token was null for the GitLab server that I had configured. I see the NPE when the authentication token is not defined. The scan works as expected when I use a valid authentication token. Thanks for the investigation!

          Then I believe we can close this ticket, arguably we can ask for a better UX in the case the token is missing or not valid, but that would be another issue I believe?

          Raul Arabaolaza added a comment - Then I believe we can close this ticket, arguably we can ask for a better UX in the case the token is missing or not valid, but that would be another issue I believe?
          Raul Arabaolaza made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

          Mark Waite added a comment -

          Would you be OK if I left this ticket open and noted that a null pointer exception is reported when the GitLab credentials are not provided? I think that a null pointer exception is not a good user experience.

          Mark Waite added a comment - Would you be OK if I left this ticket open and noted that a null pointer exception is reported when the GitLab credentials are not provided? I think that a null pointer exception is not a good user experience.

            the_jsc_ Jagrat
            markewaite Mark Waite
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: