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

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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.

            Assignee:
            Vivek Pandey
            Reporter:
            Cliff Meyers
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: