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

NullPointerException when scan bitbucket multi-branch (deleted fork)

XMLWordPrintable

    • bitbucket-branch-source:2.9.0

      Branch Indexing fails with a NullPointedException if the PR source repository does not exists anymore.

      ERROR: [Wed Jun 24 02:58:56 UTC 2020] Could not fetch branches from source com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator::https://bitbucket.org::username::repo
      java.lang.NullPointerException
      	at com.cloudbees.jenkins.plugins.bitbucket.client.pullrequest.BitbucketPullRequestValueRepository.<init>(BitbucketPullRequestValueRepository.java:51)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.call(AnnotatedConstructor.java:124)
      	at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:283)
      Caused: com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `com.cloudbees.jenkins.plugins.bitbucket.client.pullrequest.BitbucketPullRequestValueRepository`, problem: `java.lang.NullPointerException`
       at [Source: (StringReader); line: 1, column: 2569] (through reference chain: com.cloudbees.jenkins.plugins.bitbucket.client.pullrequest.BitbucketPullRequests["values"]->java.util.ArrayList[0]->com.cloudbees.jenkins.plugins.bitbucket.client.pullrequest.BitbucketPullRequestValue["source"])
      	at com.fasterxml.jackson.databind.exc.ValueInstantiationException.from(ValueInstantiationException.java:47)
      	at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:1754)
      	at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.wrapAsJsonMappingException(StdValueInstantiator.java:491)
      	at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.rewrapCtorProblem(StdValueInstantiator.java:514)
      	at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromObjectWith(StdValueInstantiator.java:285)
      	at com.fasterxml.jackson.databind.deser.ValueInstantiator.createFromObjectWith(ValueInstantiator.java:229)
      	at com.fasterxml.jackson.databind.deser.impl.PropertyBasedCreator.build(PropertyBasedCreator.java:202)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:424)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1310)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:331)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
      	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:285)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
      	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
      	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)
      	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156)
      	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4482)
      	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3447)
      	at com.cloudbees.jenkins.plugins.bitbucket.JsonParser.toJava(JsonParser.java:55)
      	at com.cloudbees.jenkins.plugins.bitbucket.JsonParser.toJava(JsonParser.java:47)
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getPullRequests(BitbucketCloudApiClient.java:302)
      Caused: java.io.IOException: I/O error when parsing response from URL: https://api.bitbucket.org/2.0/repositories/username/repo/pullrequests?page=1&pagelen=50
      	at com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient.getPullRequests(BitbucketCloudApiClient.java:304)
      	at com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource$1.create(BitbucketSCMSource.java:554)
      [...]
      

      How to Reproduce

      • Setup Multibranch and include PR from forks
      • Create a PR from a fork
      • Delete the Fork
      • Run the scan

      It fails with the above exception.

      Further Information

      Here is an example payload for the source from Bitbucket cloud:

      [...]
                  "source": {
                      "branch": {
                          "name": "branch-from-fork"
                      },
                      "commit": null,
                      "repository": null
                  },
      [...]
      

      Workaround

      Decline the PR and scan again.

            allan_burdajewicz Allan BURDAJEWICZ
            allan_burdajewicz Allan BURDAJEWICZ
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: