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

Github /organizations API returns 500 when using credentialId tied to revoked Github personal access token

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • blueocean-plugin
    • None
    • iapetus, 1.0

      Steps to reproduce:

      1. Generate a valid Github access token
      2. Use the /scm/github/validate endpoint to validate and create the credential
      3. Return to Github UI and revoke the access token
      4. Call /scm/github and note the credential is returned
      5. Call /scm/github/organizations?credentialId=github and note the 500 error

      Response body:

      {
          "message" : "Server returned HTTP response code: 401, message: 'Unauthorized' for URL: https://api.github.com/user",
          "code" : 500,
          "errors" : [ ]
      }
      

      Possible solutions

      1. I think ideally the /scm/github would re-validate the credential and return an error response if Github indicates the access token is invalid. From the UI's standpoint it would be helpful to discover this as early in the flow as possible. However, I know there would be a performance or rate-limit impact to doing this every time, so I understand if we decide not to go that route.
      2. Whether we do the above or not, I think the /organizations API should not return a 500 but perhaps instead a 403 (or 401) indicating that access was denied by Github.

      Note: this same issue also affects the /organizations/repositories API as well.

            vivek Vivek Pandey
            cliffmeyers Cliff Meyers
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: