Skip to content

Better feedback when gh pr create --reviewer fails due to fine-grained access token not having "Organization: Member" permissions #7978

Description

@Thunderforge

CLI Feedback

Consider the following:

  1. A fine-grained access token exists for a particular repo
  2. That token has the "Repository: Pull requests" permission and nothing else
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions