Uploaded image for project: 'Jira Software Data Center'
  1. Jira Software Data Center
  2. JSWSERVER-14308

Unable to link selected repository - NullPointerException linking GitHub repositories

      NOTE: This bug report is for JIRA Software Server. Using JIRA Software Cloud? See the corresponding bug report.

      On the DVCS Accounts page, linking a unlinked repo results in the following error:

      The corresponding GitHub repo is public.

      There is an NPE in the server log:

      2014-04-10 19:31:58.294877500 2014-04-10 19:31:58,291 TP-Processor6 ERROR sysadmin 1171x14227x1 1n1lb8u 59.167.133.100,131.103.26.179 /rest/bitbucket/1.0/repo/210/autolink [common.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: null
      2014-04-10 19:31:58.294880500 java.lang.NullPointerException
      2014-04-10 19:31:58.294880500 	at com.atlassian.jira.plugins.dvcs.spi.github.GithubCommunicator.ensureHookPresent(GithubCommunicator.java:355)
      2014-04-10 19:31:58.294882500 	at com.atlassian.jira.plugins.dvcs.service.remote.CachingCommunicator.ensureHookPresent(CachingCommunicator.java:226)
      2014-04-10 19:31:58.294904500 	at com.atlassian.jira.plugins.dvcs.service.RepositoryServiceImpl.addOrRemovePostcommitHook(RepositoryServiceImpl.java:530)
      2014-04-10 19:31:58.294905500 	at com.atlassian.jira.plugins.dvcs.service.RepositoryServiceImpl.enableRepository(RepositoryServiceImpl.java:480)
      2014-04-10 19:31:58.294907500 	at com.atlassian.jira.plugins.dvcs.rest.RootResource.enableRepositoryAutolink(RootResource.java:393)
      

        1. dvcs-link-error.png
          dvcs-link-error.png
          26 kB
        2. github-webhook-error.png
          github-webhook-error.png
          11 kB

          Form Name

            [JSWSERVER-14308] Unable to link selected repository - NullPointerException linking GitHub repositories

            Great that this is fixed – when will the fix be deployed/applied to Atlassian OnDemand instances?

            Thanks!

            Themis Solutions added a comment - Great that this is fixed – when will the fix be deployed/applied to Atlassian OnDemand instances? Thanks!

            Same here - deleting all existing hooks (in our case it was email and travis), disconnecting the existing DVCS account and re-registering it worked.

            Barak Merimovich added a comment - Same here - deleting all existing hooks (in our case it was email and travis), disconnecting the existing DVCS account and re-registering it worked.

            I can confirm that deleting hooks using the GitHub API DELETE /hooks/id method, including HipChat, and then linking the repository in DVCS Accounts resolves the issue.

            It's cumbersome when there are many repos involved so I look forward to a fix for the root issue in JIRA.

            John Robinson added a comment - I can confirm that deleting hooks using the GitHub API DELETE /hooks/id method, including HipChat, and then linking the repository in DVCS Accounts resolves the issue. It's cumbersome when there are many repos involved so I look forward to a fix for the root issue in JIRA.

            ZehuaA added a comment -

            I don't have any webhooks in the repository that can't be linked and the JIRA service is greyed out.

            will14 could you try to run the following command line to see if there are any hooks?

            curl -u githubusername:githubpassword https://api.github.com/repos/{github_account}/{github_repo}/hooks
            

            ZehuaA added a comment - I don't have any webhooks in the repository that can't be linked and the JIRA service is greyed out. will14 could you try to run the following command line to see if there are any hooks? curl -u githubusername:githubpassword https://api.github.com/repos/{github_account}/{github_repo}/hooks

            ZehuaA added a comment -

            themis, your case would require the bug fix to be deployed. We will update when we have the deployment scheduled.

            For now, you might want to try the following:

            1. Delete the HipChat hook
            2. Try to link the repository in DVCS Accounts page again
            3. Add the HipChat hook back again

            ZehuaA added a comment - themis , your case would require the bug fix to be deployed. We will update when we have the deployment scheduled. For now, you might want to try the following: Delete the HipChat hook Try to link the repository in DVCS Accounts page again Add the HipChat hook back again

            Themis Solutions added a comment - - edited

            For example, Zehau, one of our repositories (which refuses to be linked) has only one hook listed in the output from:

            curl -u githubusername:githubpassword https://api.github.com/repos/{github_account}/{github_repo}/hooks
            

            ... and it is a hook into HipChat, which shouldn't conflict with a hook into JIRA.

            Themis Solutions added a comment - - edited For example, Zehau, one of our repositories (which refuses to be linked) has only one hook listed in the output from: curl -u githubusername:githubpassword https://api.github.com/repos/{github_account}/{github_repo}/hooks ... and it is a hook into HipChat, which shouldn't conflict with a hook into JIRA.

            @zliu

            I don't have any webhooks in the repository that can't be linked and the JIRA service is greyed out.

            Will Watson added a comment - @zliu I don't have any webhooks in the repository that can't be linked and the JIRA service is greyed out.

            @zliu,

            I checked through – some of our repositories have the "old" JIRA link in them; some of them don't. I can't link either repositories that have the deprecated link nor ones that do not. I tried removing the deprecated link in the GitHub interface (which was successful); but I was still unable to link the repositories. Under the 'Services' tab of the GitHub webhook settings, the JIRA line is greyed out and doesn't show any exclamation mark or sign that it is active, both in the repositories that I manually cleared the webhook link from and also in the repositories that didn't have a webhook link.

            Thanks – looking forward to a fix for this.

            Themis Solutions added a comment - @zliu, I checked through – some of our repositories have the "old" JIRA link in them; some of them don't. I can't link either repositories that have the deprecated link nor ones that do not. I tried removing the deprecated link in the GitHub interface (which was successful); but I was still unable to link the repositories. Under the 'Services' tab of the GitHub webhook settings, the JIRA line is greyed out and doesn't show any exclamation mark or sign that it is active, both in the repositories that I manually cleared the webhook link from and also in the repositories that didn't have a webhook link. Thanks – looking forward to a fix for this.

            That did the trick.

            For the record, two sets of id's were returned. One for the non existant past user and another. I deleted both then added everything again. This time I could leave both boxes ticked and it didn't error.

            Appreciate the help, hopefully this will help others.

            Dale Fraser added a comment - That did the trick. For the record, two sets of id's were returned. One for the non existant past user and another. I deleted both then added everything again. This time I could leave both boxes ticked and it didn't error. Appreciate the help, hopefully this will help others.

            ZehuaA added a comment - - edited

            One unofficial way to "clear" an unwanted services/webhooks from GitHub is to go via their api: https://developer.github.com/v3/repos/hooks/

            NOTE: This method has only been tested with one GitHub account. Please read the GitHub api doc above carefully before you proceed to run any api call.

            1. Firstly, for a repository, run the GET api to find all webhooks and services configured:

            curl -u githubusername:githubpassword https://api.github.com/repos/{github_account}/{github_repo}/hooks
            

            2. And then find the id of the hook that has the name "jira" or whichever that has an alert icon when clicking on "Configure Services". For example:

              {
                "url": "https://api.github.com/repos/github_account/github_repo/hooks/1234567",
                "test_url": "https://api.github.com/repos/github_account/github_repo/hooks/1234567/test",
                "id": 1234567,
                "name": "jira",
                "active": false,
                "events": [
            

            3. Take the "id" value and or the "url" and run a DELETE api call:

            curl -XDELETE -u githubusername:githubpassword https://api.github.com/repos/github_account/github_repo/hooks/1234567
            

            4. Repeat 1 to 3 for another affected repo.

            Once you get to a state where you don't see any alert icon like this, try to refresh the DVCS Accounts page and link the affected repos again.

            Note that it's not just the "Jira" service that should not have an alert icon. Any other services that have an alert icon would cause this problem.

            ZehuaA added a comment - - edited One unofficial way to "clear" an unwanted services/webhooks from GitHub is to go via their api: https://developer.github.com/v3/repos/hooks/ NOTE: This method has only been tested with one GitHub account. Please read the GitHub api doc above carefully before you proceed to run any api call. 1. Firstly, for a repository, run the GET api to find all webhooks and services configured: curl -u githubusername:githubpassword https://api.github.com/repos/{github_account}/{github_repo}/hooks 2. And then find the id of the hook that has the name "jira" or whichever that has an alert icon when clicking on "Configure Services". For example: { "url" : "https: //api.github.com/repos/github_account/github_repo/hooks/1234567" , "test_url" : "https: //api.github.com/repos/github_account/github_repo/hooks/1234567/test" , "id" : 1234567, "name" : "jira" , "active" : false , "events" : [ 3. Take the "id" value and or the "url" and run a DELETE api call: curl -XDELETE -u githubusername:githubpassword https://api.github.com/repos/github_account/github_repo/hooks/1234567 4. Repeat 1 to 3 for another affected repo. Once you get to a state where you don't see any alert icon like this, try to refresh the DVCS Accounts page and link the affected repos again. Note that it's not just the "Jira" service that should not have an alert icon. Any other services that have an alert icon would cause this problem.

              zliu ZehuaA
              zliu ZehuaA
              Affected customers:
              7 This affects my team
              Watchers:
              24 Start watching this issue

                Created:
                Updated:
                Resolved: