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

null permission lookup when pull-request's origin repo/branch is deleted on github

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None

      We use GitHub Organizations to manage our jobs.

      We found a bug where if a pull request has its source repository/branch deleted (e.g. it was a personal fork and that personal fork was deleted) then that repository stops updating from github.

      Here is the log from the "Scan Repository Log':

          Checking pull request #154
      ERROR: [Fri Apr 12 16:39:29 EDT 2019] Could not fetch branches from source org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator::https://github.example.com/api/v3::robert-continuous-delivery::howard
      java.io.FileNotFoundException: https://github.example.com/api/v3/repos/robert-continuous-delivery/howard/collaborators/null/permission
      	at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
      	at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
      	at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
      	at org.kohsuke.github.Requester.parse(Requester.java:625)
      	at org.kohsuke.github.Requester.parse(Requester.java:607)
      	at org.kohsuke.github.Requester._to(Requester.java:285)
      Caused: org.kohsuke.github.GHFileNotFoundException: {"message":"null is not a user","documentation_url":"https://developer.github.com/enterprise/2.16/v3/repos/collaborators/#review-a-users-permission-level"}
      	at org.kohsuke.github.Requester.handleApiError(Requester.java:699)
      	at org.kohsuke.github.Requester._to(Requester.java:306)
      	at org.kohsuke.github.Requester.to(Requester.java:247)
      	at org.kohsuke.github.GHRepository.getPermission(GHRepository.java:529)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$1.fetch(GitHubSCMSource.java:904)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceRequest.getPermissions(GitHubSCMSourceRequest.java:474)
      	at org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission.checkTrusted(ForkPullRequestDiscoveryTrait.java:344)
      	at org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission.checkTrusted(ForkPullRequestDiscoveryTrait.java:327)
      	at jenkins.scm.api.trait.SCMHeadAuthority.isTrusted(SCMHeadAuthority.java:101)
      	at jenkins.scm.api.trait.SCMSourceRequest.isTrusted(SCMSourceRequest.java:213)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$3.create(GitHubSCMSource.java:970)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$3.create(GitHubSCMSource.java:964)
      	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:339)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:960)
      	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
      	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
      	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      [Fri Apr 12 16:39:29 EDT 2019] Finished branch indexing. Indexing took 3.6 sec
      FATAL: Failed to recompute children of Jenkins: Continuous Delivery » howard
      org.kohsuke.github.GHFileNotFoundException: {"message":"null is not a user","documentation_url":"https://developer.github.com/enterprise/2.16/v3/repos/collaborators/#review-a-users-permission-level"}
      	at org.kohsuke.github.Requester.handleApiError(Requester.java:699)
      	at org.kohsuke.github.Requester._to(Requester.java:306)
      	at org.kohsuke.github.Requester.to(Requester.java:247)
      	at org.kohsuke.github.GHRepository.getPermission(GHRepository.java:529)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$1.fetch(GitHubSCMSource.java:904)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceRequest.getPermissions(GitHubSCMSourceRequest.java:474)
      	at org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission.checkTrusted(ForkPullRequestDiscoveryTrait.java:344)
      	at org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait$TrustPermission.checkTrusted(ForkPullRequestDiscoveryTrait.java:327)
      	at jenkins.scm.api.trait.SCMHeadAuthority.isTrusted(SCMHeadAuthority.java:101)
      	at jenkins.scm.api.trait.SCMSourceRequest.isTrusted(SCMSourceRequest.java:213)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$3.create(GitHubSCMSource.java:970)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$3.create(GitHubSCMSource.java:964)
      	at jenkins.scm.api.trait.SCMSourceRequest.process(SCMSourceRequest.java:339)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:960)
      	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
      	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
      	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      Caused by: java.io.FileNotFoundException: https://github.example.com/api/v3/repos/robert-continuous-delivery/howard/collaborators/null/permission
      	at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
      	at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
      	at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
      	at org.kohsuke.github.Requester.parse(Requester.java:625)
      	at org.kohsuke.github.Requester.parse(Requester.java:607)
      	at org.kohsuke.github.Requester._to(Requester.java:285)
      	... 20 more
      Finished: FAILURE
      

          [JENKINS-56996] null permission lookup when pull-request's origin repo/branch is deleted on github

          Liam Newman added a comment -

          docwhat
          So, the issue is that the updating of all PRs stops, not that this one PR doesn't refresh (which is understandable). Is that correct?

          Liam Newman added a comment - docwhat So, the issue is that the updating of all PRs stops, not that this one PR doesn't refresh (which is understandable). Is that correct?

          So, the issue is that the updating of all PRs stops, not that this one PR doesn't refresh (which is understandable). Is that correct?

          The scanning for the entire organization folder (and down) stops, nothing new gets added or removed.

          Christian Höltje added a comment - So, the issue is that the updating of all PRs stops, not that this one PR doesn't refresh (which is understandable). Is that correct? The scanning for the entire organization folder (and down) stops, nothing new gets added or removed.

          Liam Newman added a comment -

          docwhat
          Right, that's what I thought you were saying. Thanks, I'm working on this.

          Liam Newman added a comment - docwhat Right, that's what I thought you were saying. Thanks, I'm working on this.

          Liam Newman added a comment - - edited

          Wow.
          I did some digging on this and it is not particularly easy.

          I'd love to be able to simply catch and swallow some error locally, but if we do that it may result in jobs being deleted (or marked for deletion) simply because there was an error while reading them. I looked pretty carefully and I didn't see a way to address this safely in a small/local change.

          The core problem is that the code that controls how child items are created and maintained is spread across several other plugins, including folders, scm-api and branch-api.

          My thought is that we'll need to add a no-op preserve(String itemName) method to SCMHeadObserver.

          Then we can wire through an implementation in MultiBranchProject.SCMHeadObserverImpl.

          Finally, we'd expose that in github-branch-source for the GitHubSCMSource to call when an error occurs.

          I suppose it would okay for PRs specifically to simply be deleted on FileNotFoundException specifically, but not great behavior.

          Liam Newman added a comment - - edited Wow. I did some digging on this and it is not particularly easy. I'd love to be able to simply catch and swallow some error locally, but if we do that it may result in jobs being deleted (or marked for deletion) simply because there was an error while reading them. I looked pretty carefully and I didn't see a way to address this safely in a small/local change. The core problem is that the code that controls how child items are created and maintained is spread across several other plugins, including folders, scm-api and branch-api. My thought is that we'll need to add a no-op preserve(String itemName) method to SCMHeadObserver . Then we can wire through an implementation in MultiBranchProject.SCMHeadObserverImpl . Finally, we'd expose that in github-branch-source for the GitHubSCMSource to call when an error occurs. I suppose it would okay for PRs specifically to simply be deleted on FileNotFoundException specifically, but not great behavior.

          Liam Newman added a comment -

          docwhat

          Please try this version: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/github-branch-source/2.5.2-rc835.5125eb8241d3/

          It should make you scan not fail due to issues with one PR. NOTE: PRs that experience errors will be marked "orphaned" (and possibly deleted depending on your orphan strategy).

          Liam Newman added a comment - docwhat Please try this version: https://repo.jenkins-ci.org/incrementals/org/jenkins-ci/plugins/github-branch-source/2.5.2-rc835.5125eb8241d3/ It should make you scan not fail due to issues with one PR. NOTE: PRs that experience errors will be marked "orphaned" (and possibly deleted depending on your orphan strategy).

          Liam Newman added a comment -

          I'm going to resolve this as fixed and move forward.
          docwhat Please comment if this is not fixed for you.

          Liam Newman added a comment - I'm going to resolve this as fixed and move forward. docwhat Please comment if this is not fixed for you.

          Liam Newman added a comment -

          Released as part of v2.5.2, waiting to close until we hear from reporter.

          Liam Newman added a comment - Released as part of v2.5.2, waiting to close until we hear from reporter.

            bitwiseman Liam Newman
            docwhat Christian Höltje
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: