Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error trying to request PR review from a team within GHE #981

Open
shyamkrishnan-b opened this issue Aug 8, 2019 · 11 comments

Comments

@shyamkrishnan-b
Copy link

commented Aug 8, 2019

Bug Report

Current Behavior
I am trying to request review from a team on all my PRs. The team slugs are passed into the following method as an array

if (reviewers.length > 0 || team_reviewers.length > 0) {               
                try {
                    await context.github.pullRequests.createReviewRequest(context.repo({
                        number: pull_request.number,
                        reviewers: reviewers,
                        team_reviewers: team_reviewers
                    }));
                } catch (err) {
                    console.log(err.message);
                    let error = JSON.parse(err.message);
                    result = error.message;
                }
            }

Expected behavior/code
Expected behavior is for the team slugs to be added as reviewers on the PR

Environment

  • Probot version(s): 7.4.0
  • Node/npm version: 10.14.1
  • OS: RHEL and Windows 10
  • GHE : 2.17.5

Possible Solution

Additional context/Screenshots
Error message we receive is {"message":"Validation Failed","errors":["Could not resolve to a node with the global id of 'MDQ6VGVhbTI0MQ=='."],"documentation_url":"https://developer.github.com/enterprise/2.17/v3/pulls/review_requests/#create-a-review-request"}

The node_id in the error is for the team which is in the array. We are able to pull the team via Github API and also able to request review when ran through the Github API

@welcome

This comment has been minimized.

Copy link

commented Aug 8, 2019

Thanks for opening this issue. A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines and explore other ways you can get involved.

@issue-label-bot issue-label-bot bot added the bug 🐞 label Aug 8, 2019

@issue-label-bot

This comment has been minimized.

Copy link

commented Aug 8, 2019

Issue-Label Bot is automatically applying the label bug 🐞 to this issue, with a confidence of 0.94. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@shyamkrishnan-b shyamkrishnan-b changed the title Error trying to PR review request from a team within GHE Error trying to request PR review from a team within GHE Aug 8, 2019

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2019

reviewers and team_reviewers should be arrays of the logins, see example: https://developer.github.com/enterprise/2.17/v3/pulls/review_requests/#example

are you passing node_ids instead?

GitHub Developer
Get started with one of our guides, or jump straight into the API documentation.
@shyamkrishnan-b

This comment has been minimized.

Copy link
Author

commented Aug 12, 2019

@gr2m We are sending in array of user logins for reviewers and array of team slugs for team_reviewers.
The method call works correctly for user logins but gives the above error for team slugs.

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

Could you please try to send the request using curl? There might be an API bug, if you can reproduce the problem with curl, send a message to support@github.com to let them know, together with the curl command (with redacted credentials) and response. You can reference this issue

@shyamkrishnan-b

This comment has been minimized.

Copy link
Author

commented Aug 13, 2019

@gr2m I tried the API call with a Postman request (with same Github team slug) and it was successful.

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

Can you log out error.request and paste it here?

@shyamkrishnan-b

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

@gr2m I have been trying to log the request being made but have not been able to. I changed the log-level to debug and get the below log snippet which gives info around the probot request.

19:52:56.933Z DEBUG github: GitHub request: POST /repos/:owner/:repo/pulls/:number/requested_reviewers - 422 undefined (id=43048830-ba19-11e9-8b10-bab764c9fa07, installation=17)
  params: {
    "owner": "InformationSystems",
    "repo": "bots-test",
    "number": 2,
    "pull_number": 2,
    "team_reviewers": [
      "bot-test"
    ],
    "baseUrl": "https://XXXXXX.com/api/v3",
    "request": {
      "timeout": 0
    }
  }

Following is the response we get

{ HttpError: {"message":"Validation Failed","errors":["Could not resolve to a node with the global id of 'MDQ6VGVhbTI0MQ=='."],"documentation_url":"https://developer.github.com/enterprise/2.17/v3/pulls/review_requests/#create-a-review-request"}
    at response.text.then.message (XXXXXXXX\nodejs\node-v10.14.1-win-x64\node_modules\probot\node_modules\@octokit\rest\lib\request\request.js:72:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HttpError',
  code: 422,
  status: undefined,
  headers:
   { 'access-control-allow-origin': '*',
     'access-control-expose-headers':
      'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type',
     connection: 'close',
     'content-length': '231',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Wed, 14 Aug 2019 19:52:56 GMT',
     'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
     server: 'GitHub.com',
     status: '422 Unprocessable Entity',
     'strict-transport-security': 'max-age=31536000; includeSubdomains',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-enterprise-version': '2.17.5',
     'x-github-media-type': 'github.v3; format=json',
     'x-github-request-id': '9580405-ddfg-4p58-62f9-ec8e788c1a49',
     'x-runtime-rack': '0.222847',
     'x-xss-protection': '1; mode=block' } }```
@shyamkrishnan-b

This comment has been minimized.

Copy link
Author

commented Aug 14, 2019

I can take the exact request ,run it via github api on the same endpoint and it works. We have tried changing permissions on the Github app and have not helped.

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

Hmm do you use the latest version of probot? It should include the latest version of @octokit/rest. The response you shared should have a request key which shows the request.

Could you try to reproduce the same problem on api.github.com? If yes, we could create a small demo that we could collaborate on. When I can reproduce it myself, I'm sure I can find out what the problem is

@shyamkrishnan-b

This comment has been minimized.

Copy link
Author

commented Aug 20, 2019

@gr2m We were able to resolve it by tweaking the app permissions. I think adding "Repository Metadata" permissions to read-only did the trick. In the process we upgraded to use the latest version of probot and it helps a lot with the additional logging.

Thank you for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.