← 输入框|github.com|刷新
Skip to content

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

Open

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.

Activity

  1. added
    bugSomething isn't working
    on Sep 15, 2022
  2. added
    priority-2Affects more than a few users but doesn't prevent core functions
    and removed on Sep 15, 2022
  3. mislav commented on Sep 15, 2022

    @mislav
    Contributor

    Thank you for reporting! Fully agreed with your assessment of the bug.

    Semi-related: #4631 #4876

  4. scottdickerson commented on Oct 20, 2022

    @scottdickerson

    The workaround that @nzig came up with worked well until today:

    permissions:
      packages: write # needed for push of package
      contents: write # needed for push of tags
      pull-requests: read # needed to view the PR for the slack
      repository-projects: read # needed for view the PR for the slack https://github.com/cli/cli/issues/6274
    

    However, it seems to be newly broken again today:

    GraphQL: Resource not accessible by integration (repository.pullRequest.statusCheckRollup.nodes.0.commit.statusCheckRollup)
    
  5. Bikram-DoorDash commented on Aug 30, 2023

    @Bikram-DoorDash

    I added gh pr edit to my script today and got the Resource not accessible by integration error. Stumbled onto this page on Googling. It's been ~1 year since this issue was opened. :( Hope this gets some traction soon.

  6. danielkimuipath commented on Oct 4, 2023

    @danielkimuipath

    Im having this issue as well - anyone got it working with GitHub App ? is there any particular permission needs to be added besides PullRequest (read and write) and repository(read and write)?

  7. jenseng commented on Oct 4, 2023

    @jenseng

    However, it seems to be newly broken again today:
    GraphQL: Resource not accessible by integration (repository.pullRequest.statusCheckRollup.nodes.0.commit.statusCheckRollup)

    I ran into this error when using gh pr list ..., and was able to resolve it by adding statuses and checks permissions to my job, e.g.

    permissions:
      pull-requests: read
      statuses: read
      checks: read
      # you might need even more permissions, depending on what you're doing 😄 
  8. vyas-n commented on May 13, 2024

    @vyas-n

    Seems to have the same problem even outside of github actions workflows: https://github.com/orgs/community/discussions/111324

  9. siddhantsoni commented on May 31, 2024

    @siddhantsoni

    Faced this exact issue when trying to edit PT title using our Github bot. Took a long time to figure out that we need to give extra project:read permission to the bot to perform this simple task.
    It would be a great help if this gets fixed!

  10. 19 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandpitchpitched internally for prioritisationpriority-2Affects more than a few users but doesn't prevent core functions

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions