Skip to content

gh pr edit does not work with only pull-requests: write permissions #6274

@nzig

Description

@nzig

Describe the bug

I have a GitHub actions that runs gh pr edit using the GITHUB_TOKEN created automatically for the job.

When I added

permissions:
  pull-requests: write

to the workflow definition I started to get

GraphQL: Resource not accessible by integration (repository.pullRequest.projectCards.nodes)

I think it is because of this line:

editable.Projects.Default = pr.ProjectCards.ProjectNames()

where the CLI tries to get the project names, but this requires the repository-projects: read permission.

Adding repository-projects: read fixes the problem, but this took me a while to figure out and should be fixed IMO, since edits to a PR that don't involve projects shouldn't require that permission.

I am using the latest CLI version as intalled in the ubuntu-latest GitHub Actions image.

Steps to reproduce the behavior

  1. Create a workflow with only pull-requests: write permissions
  2. Create a step that runs gh pr edit ...
  3. See error

Expected vs actual behavior

The gh pr edit command should succeed without additional permissions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandp2Affects more than a few users but doesn't prevent core functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions