You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better feedback when gh pr create --reviewer fails due to fine-grained access token not having "Organization: Member" permissions #7978
A fine-grained access token exists for a particular repo
That token has the "Repository: Pull requests" permission and nothing else
An end-user runs gh pr create […] --reviewer FooTeam to create a new PR with the FooTeam Team as a reviewer
In this case, the request fails with this message:
GraphQL: Resource not accessible by personal access token (organization.t000)
The problem
The error does not clearly indicate what the problem is and is confusing to debug.
The reason the request was rejected is that the fine-grained access token does not have the "Organization: Member" permission and thus cannot validate that the Team in question exists.
As-is, this is not communicated well. It is not immediately apparent that the request failed due to the --reviewer flag and that organization.t000 corresponds with FooTeam. No information is given about how to resolve the issue.
Possible solutions
Some possible alternative error messages that would clarify the situation:
Cannot set reviewers because personal access token does not have "Organization: Member" permissions
Personal access token is unable to access reviewer "FooTeam"
Reviewer not accessible by personal access token (FooTeam)
Personal access token cannot set reviewers due to lacking "Organization: Member" permissions
Reacted by Alfredo Fiebig, Luis A Rayas, Dan Gealow and Mario Campos
Hi @Thunderforge, thanks for the feedback and sorry you ran into some confusing behaviour. I've collected the output with GH_DEBUG=api here for posterity:
And indeed, after providing read-only access to Organization: members this was successful.
What can we do?
As we can see from the GQL response, we don't get much back from the server in terms of missing permission information, and I would hesitate to try and recreate any of the resource checks within the CLI. That said, if we look at the error message:
GraphQL: Resource not accessible by personal access token (organization.t000)
I think that a more obvious mapping between t000 and the codespacesslug would indeed help.
I've had some time to think about why I was confused about the error message.
GraphQL: Resource not accessible by personal access token (organization.t000)
The problems are:
It was not immediately clear which "resource" is being discussed
"Organization" did not bring to mind Teams
I didn't know that the "Organization: Member" permission even existed or was tied to PR reviewers
1. It was not immediately clear which "resource" is being discussed
Because I was trying to create a pull request, my assumption was that the pull request itself (or alternatively the branch or repo) was the resource it said not accessible. Therefore I spent lots of time double-checking that my token had the "Pull Requests" and "Contents" permissions.
This was probably a tunnel vision problem. I had a very specific goal and reviewers being at fault just wasn't on my radar. It's operator error, but if I wasn't making the mental link, others are likely to make the same.
(For what it's worth though: I did assume that "Pull Requests" permission would be sufficient for all flags to work as intended. I'm guessing it's a long shot, but if that could happen, that would be super helpful).
2. "Organization" did not bring to mind Teams
For instance, we have our private repo at FooCompany/BarRepo, and it's associated with "FooTeam" and "BazTeam".
I think I've seen "Organization" used to refer to what "FooCompany" is, but I don't think I've ever seen it applied to what "FooTeam" is. Therefore it seemed like organization.t000 was referring to the entire namespace of FooCompany, which probably meant some sort of repo access issue.
If instead it said team.t000, that might have brought to mind it faster. Of course, the exact name of the team would have been even better.
Edit: After I had written up this post, it finally hit me that the t in organization.t000 might stand for "Team". That certainly wasn't obvious to me at the time; it took me a full week after making my original post to make that connection! Had it said organization.team000, I still would have been confused about why the PR wasn't getting created, but I would have maybe figured it out faster.
3. I didn't know that the "Organization: Member" permission even existed or was tied to PR reviewers
So far, all of my investigation of fine-grained token permissions had been focused on the repository groups. I took one look at Organization, saw that it was for a bunch of stuff that didn't seem to apply to pull requests, and I ignored it.
Honestly, the way I figured out the need for that permission was:
Carefully check if I had repository permissions I thought I needed (e.g. "Repository: Pull Request"), only to see it fail
In desperation, enable all Repository permissions, only to see it fail
In desperation, enable all Organization permissions, which succeeded
Systematically turn them off until I figured out that I needed "Organization: Members"
Therefore, my ideal solution would be an error message that specifically tells you that the fine-grained token lacks the particular permission, referred to by name. The actionable item is clear: if you want to use the token for this operation, you need to give it that permission.
Anyway, I hope this feedback is helpful. Thank you for the detailed investigation you have done so far. Let me know if I can help in any other way.
Personally, I'd like to understand what the consequence of changing this to be the actual team name would be in terms of our query. In this case, the error would read:
GraphQL: Resource not accessible by personal access token (organization.FooTeam)
Which would hopefully far more quickly address the very reasonable mental connections you made in points 1 and 2.
In terms of point 3, we are limited by the responses of the API. In good news, they do have a plan to provide more granular errors but there's no indication of when that work will actually occur. I have included this issue as motivation (so thanks for the detailed write up again).
@williammartin Thanks for doing this, and for looking at if it's possible to make the change you want. If that can be made, I think that would satisfy this feature request. Had the error said
GraphQL: Resource not accessible by personal access token (organization.FooTeam)
I think I would have definitely figured out that the issue was that it couldn't access the team, rather than some access issue with the pull request as I had assumed (the "organization" would have still confused me, but it probably wouldn't have stopped me from figuring it out eventually).
I'm happy to hear that there are more granular errors planned for the future, and that my issue is helping to spur them on.
I'm labelling this core as I think there is value in modifying the t000 schema to something that provides a more useful error message but I don't feel confident enough that there are no side effects of that to ask for help from the community without doing some more investigation (unless someone wants to spend the time looking into that separately, which I would welcome).
Going to close this for now since #12627 merged, but please get back to us if the next release 2.88.0 does not improve/resolve this. For now this fix is only available on Github.com.
Activity
williammartin commentedon Sep 18, 2023
Hi @Thunderforge, thanks for the feedback and sorry you ran into some confusing behaviour. I've collected the output with
GH_DEBUG=apihere for posterity:And indeed, after providing read-only access to
Organization: membersthis was successful.What can we do?
As we can see from the
GQLresponse, we don't get much back from the server in terms of missing permission information, and I would hesitate to try and recreate any of the resource checks within the CLI. That said, if we look at the error message:And compare it to our query:
Perhaps we could provide a more obvious mapping between
t000and thecodespacesslug.I'm not aware of the historical context behind these
t000shaped names that were introduced in #908, so I'll need to do more digging.Thunderforge commentedon Sep 19, 2023
I think that a more obvious mapping between
t000and thecodespacesslugwould indeed help.I've had some time to think about why I was confused about the error message.
The problems are:
1. It was not immediately clear which "resource" is being discussed
Because I was trying to create a pull request, my assumption was that the pull request itself (or alternatively the branch or repo) was the resource it said not accessible. Therefore I spent lots of time double-checking that my token had the "Pull Requests" and "Contents" permissions.
This was probably a tunnel vision problem. I had a very specific goal and reviewers being at fault just wasn't on my radar. It's operator error, but if I wasn't making the mental link, others are likely to make the same.
(For what it's worth though: I did assume that "Pull Requests" permission would be sufficient for all flags to work as intended. I'm guessing it's a long shot, but if that could happen, that would be super helpful).
2. "Organization" did not bring to mind Teams
For instance, we have our private repo at
FooCompany/BarRepo, and it's associated with "FooTeam" and "BazTeam".I think I've seen "Organization" used to refer to what "FooCompany" is, but I don't think I've ever seen it applied to what "FooTeam" is. Therefore it seemed like
organization.t000was referring to the entire namespace of FooCompany, which probably meant some sort of repo access issue.If instead it said
team.t000, that might have brought to mind it faster. Of course, the exact name of the team would have been even better.Edit: After I had written up this post, it finally hit me that the
tinorganization.t000might stand for "Team". That certainly wasn't obvious to me at the time; it took me a full week after making my original post to make that connection! Had it saidorganization.team000, I still would have been confused about why the PR wasn't getting created, but I would have maybe figured it out faster.3. I didn't know that the "Organization: Member" permission even existed or was tied to PR reviewers
So far, all of my investigation of fine-grained token permissions had been focused on the repository groups. I took one look at Organization, saw that it was for a bunch of stuff that didn't seem to apply to pull requests, and I ignored it.
Honestly, the way I figured out the need for that permission was:
Therefore, my ideal solution would be an error message that specifically tells you that the fine-grained token lacks the particular permission, referred to by name. The actionable item is clear: if you want to use the token for this operation, you need to give it that permission.
Anyway, I hope this feedback is helpful. Thank you for the detailed investigation you have done so far. Let me know if I can help in any other way.
williammartin commentedon Sep 19, 2023
@Thunderforge this is an excellent write up and I really appreciate you taking the time. Indeed, the
tint000does stand forteam: https://github.com/cli/cli/blob/trunk/api/queries_repo.go#L979.Personally, I'd like to understand what the consequence of changing this to be the actual team name would be in terms of our query. In this case, the error would read:
Which would hopefully far more quickly address the very reasonable mental connections you made in points 1 and 2.
In terms of point 3, we are limited by the responses of the API. In good news, they do have a plan to provide more granular errors but there's no indication of when that work will actually occur. I have included this issue as motivation (so thanks for the detailed write up again).
Thunderforge commentedon Sep 19, 2023
@williammartin Thanks for doing this, and for looking at if it's possible to make the change you want. If that can be made, I think that would satisfy this feature request. Had the error said
I think I would have definitely figured out that the issue was that it couldn't access the team, rather than some access issue with the pull request as I had assumed (the "organization" would have still confused me, but it probably wouldn't have stopped me from figuring it out eventually).
I'm happy to hear that there are more granular errors planned for the future, and that my issue is helping to spur them on.
williammartin commentedon Sep 27, 2023
I'm labelling this
coreas I think there is value in modifying thet000schema to something that provides a more useful error message but I don't feel confident enough that there are no side effects of that to ask for help from the community without doing some more investigation (unless someone wants to spend the time looking into that separately, which I would welcome).Thanks again for all the feedback @Thunderforge
dvg-p4 commentedon Oct 2, 2025
With the latest version of
gh, the message is somewhat better:But it would be even nicer if it could hint at "teams" permissions being a subset of "Organizations: Members"
BagToad commentedon Feb 17, 2026
This should be fixed by #12627 since we will stop pre-fetching teams on GitHub.com where we have new APIs that do not require it.
BagToad commentedon Mar 6, 2026
Going to close this for now since #12627 merged, but please get back to us if the next release
2.88.0does not improve/resolve this. For now this fix is only available on Github.com.