-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Better feedback when gh pr create --reviewer
fails due to fine-grained access token not having "Organization: Member" permissions
#7978
Comments
Hi @Thunderforge, thanks for the feedback and sorry you ran into some confusing behaviour. I've collected the output with
And indeed, after providing read-only access to What can we do?As we can see from the
And compare it to our query:
Perhaps we could provide a more obvious mapping between I'm not aware of the historical context behind these |
I think that a more obvious mapping between 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 discussedBecause 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 TeamsFor instance, we have our private repo at 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 If instead it said Edit: After I had written up this post, it finally hit me that the 3. I didn't know that the "Organization: Member" permission even existed or was tied to PR reviewersSo 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. |
@Thunderforge this is an excellent write up and I really appreciate you taking the time. Indeed, the 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). |
@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. |
I'm labelling this Thanks again for all the feedback @Thunderforge |
CLI Feedback
Consider the following:
gh pr create […] --reviewer FooTeam
to create a new PR with theFooTeam
Team as a reviewerIn this case, the request fails with this message:
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 thatorganization.t000
corresponds withFooTeam
. No information is given about how to resolve the issue.Possible solutions
Some possible alternative error messages that would clarify the situation:
The text was updated successfully, but these errors were encountered: