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

Use of team-reviewers results in: "Could not resolve to a node with the global id of..." error #155

Closed
jchoksijudopay opened this issue Apr 6, 2020 · 10 comments
Labels
has workaround This issue has a workaround

Comments

@jchoksijudopay
Copy link

Subject of the issue

Providing a GitHub team to request a review from doesn't work.

Steps to reproduce

    - name: Push changes to Github and create pull request
      if: ${{ env.CREATE_PR == 1 }}
      id: pull_request
      uses: peter-evans/create-pull-request@v2
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        title: 'Some text here...'
        body: |
          Some text here...
          - Some text here...
          - Auto-generated by [create-pull-request][1]

          [1]: https://github.com/peter-evans/create-pull-request
        labels: binupdate, automated pr
        team-reviewers: developers
        branch: binbase/update
        branch-suffix: timestamp

In the example above, developers is a valid Github team. When I base64 decode MDQ6VGVhbTE3NTI3NjE= in the error below, it resolves to: 04:Team1752761 and I can confirm that 1752761 is the correct id for our developers Github team.

The error message we see is:

Requesting team reviewers 'developers'
Traceback (most recent call last):
  File "/home/runner/work/_actions/peter-evans/create-pull-request/v2/dist/cpr/create_pull_request.py", line 213, in <module>
    coupr.create_or_update_pull_request(
  File "/home/runner/work/_actions/peter-evans/create-pull-request/v2/dist/cpr/create_or_update_pull_request.py", line 143, in create_or_update_pull_request
    pull_request.create_review_request(
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/github/PullRequest.py", line 511, in create_review_request
    headers, data = self._requester.requestJsonAndCheck(
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/github/Requester.py", line 317, in requestJsonAndCheck
    return self.__check(
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/github/Requester.py", line 342, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.GithubException: 422 {"message": "Validation Failed", "errors": ["Could not resolve to a node with the global id of 'MDQ6VGVhbTE3NTI3NjE='."], "documentation_url": "https://developer.github.com/v3/pulls/review_requests/#create-a-review-request"}
##[error]The process '/opt/hostedtoolcache/Python/3.8.2/x64/bin/python' failed with exit code 1
/usr/bin/git config --local --add http.https://github.com/.extraheader AUTHORIZATION: basic ***
@peter-evans
Copy link
Owner

Hi @jchoksijudopay

This looks like a permissions issue. Could you explain a bit more about your setup. Is the team in the same org as the repository? Does the team have collaborator (write) access to the repository? Is the repository private?

@peter-evans peter-evans added the waiting for feedback Waiting for feedback label Apr 7, 2020
@jchoksijudopay
Copy link
Author

Is the team in the same org as the repository?

Yes it is.

Does the team have collaborator (write) access to the repository?

Yes the developers team has Write role access to the repository.

We have a Nested Team structure as follows:

- WriteAccess Team (is the team that is assigned the "Write" Role to the repository)
  |--- CI Team
       |--- CI Member 1
       |--- CI Member 2
       |--- CI Member n
  |--- Developers Team
       |--- Developer Member 1
       |--- Developer Member 2
       |--- Developer Member n

Is the repository private?

Yes it is private.

@peter-evans peter-evans removed the waiting for feedback Waiting for feedback label Apr 7, 2020
@peter-evans
Copy link
Owner

I'll try and find some time to reproduce the problem and see if I can find a workaround. I'm fairly sure this is not a problem with the action itself, it's likely to be a permissions related issue with the GitHub API. One thing you could try is using a PAT instead of the default GITHUB_TOKEN. You could also experiment with a top-level (not nested) team to see if that makes a difference.

@peter-evans
Copy link
Owner

I managed to setup an org and teams in the same way and reproduced the error. I'll see if I can figure out what the issue is and any workaround.

@peter-evans
Copy link
Owner

peter-evans commented Apr 10, 2020

So it seems to be permissions related, but I’m not sure if it's intentional. It might be a GitHub API bug. The problem seems to be that the default GITHUB_TOKEN does not have permission to request a review from a team. It doesn't appear to matter whether the repository is private or not, or whether the team is nested or not.

Here is how you can work around it:

  1. Create a new GitHub account that will act as a machine user.
  2. Add the machine user to a team that has write access for the repository.
  3. Log into the machine user account and create a repo scoped PAT.
  4. Copy the generated PAT to a secret in your repository.
  5. Use the secret instead of the default GITHUB_TOKEN when running create-pull-request action.

@jchoksijudopay
Copy link
Author

Sorry for the delay in providing feedback. Using a PAT as a workaround works for us. Thank you very much for looking into the matter.

@thulasidassrinivasan
Copy link

@peter-evans - I am facing the same issue even if I use PAT token.

Below fails
- name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.user_GITHUB_TOKEN }} branch: update-flux branch-suffix: short-commit-hash commit-message: Update to ${{ steps.update.outputs.flux_version }} title: Update to ${{ steps.update.outputs.flux_version }} body: | ${{ steps.update.outputs.flux_version }} delete-branch: true author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> team-reviewers: | admin

Below works
- name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.user_GITHUB_TOKEN }} branch: update-flux branch-suffix: short-commit-hash commit-message: Update to ${{ steps.update.outputs.flux_version }} title: Update to ${{ steps.update.outputs.flux_version }} body: | ${{ steps.update.outputs.flux_version }} delete-branch: true author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> reviewers: thulasidassrinivasan

What am I doing wrong ? Could you Please help?

@loujr
Copy link

loujr commented Sep 8, 2022

Was able to reproduce the following error using a GitHub App for this endpoint - the issue is permissions.

{
  "message": "Validation Failed",
  "errors": [
    "Could not resolve to a node with the global id of 'T_kwDOBnBNDs4AYoNE'."
  ],
  "documentation_url": "https://docs.github.com/rest/reference/pulls#request-reviewers-for-a-pull-request"
}

For this endpoint to be successful the following permissions must be enabled on GitHub Apps:

Read access to metadata
Read and write access to members, pull requests, and team discussions

@shivajipotnuru
Copy link

I'm also facing the same issue with my new GitHub app,

I have given the required permissions for the app, but still I'm getting this error.

@loujr please let me know , if you are able to fix this issue?

humitos added a commit to readthedocs/sphinx-hoverxref that referenced this issue Mar 13, 2023
```
Error: Reviews may only be requested from collaborators. One or more of the
teams you specified is not a collaborator of the readthedocs/sphinx-hoverxref
repository.
```

It seems it's a permission issue. See peter-evans/create-pull-request#155 (comment)

However, we are not having this issue in .org. I'm removing the reviewers for
now just to move forward because we haven't updated the requirements in a while now.
kdambekalns added a commit to flownative/versions.flownative.io that referenced this issue Jul 7, 2023
This updates the action from v4 to v5 and replaces the use of `team-reviewers` with `reviewers`.

Background:

- peter-evans/create-pull-request#1638
- peter-evans/create-pull-request#155
@vilesa1
Copy link

vilesa1 commented Feb 5, 2024

if that helps anyone, make sure as a itemId you do not use the itemId you see in github webapp url, but rather its true node ID starting with PVTI_
you can find this ID here: https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects?tool=curl#finding-information-about-items-in-a-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has workaround This issue has a workaround
Projects
None yet
Development

No branches or pull requests

6 participants