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

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

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      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
      

        Attachments

          Issue Links

            Activity

            Hide
            bitwiseman Liam Newman added a comment -

            Christian Höltje
            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?

            Show
            bitwiseman Liam Newman added a comment - Christian Höltje 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?
            Hide
            docwhat 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.

            Show
            docwhat 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.
            Hide
            bitwiseman Liam Newman added a comment -

            Christian Höltje
            Right, that's what I thought you were saying. Thanks, I'm working on this.

            Show
            bitwiseman Liam Newman added a comment - Christian Höltje Right, that's what I thought you were saying. Thanks, I'm working on this.
            Hide
            bitwiseman 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.

            Show
            bitwiseman 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.
            Hide
            bitwiseman Liam Newman added a comment -

            Christian Höltje

            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).

            Show
            bitwiseman Liam Newman added a comment - Christian Höltje 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).
            Hide
            bitwiseman Liam Newman added a comment -

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

            Show
            bitwiseman Liam Newman added a comment - I'm going to resolve this as fixed and move forward. Christian Höltje Please comment if this is not fixed for you.
            Hide
            bitwiseman Liam Newman added a comment -

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

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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: