Skip to content

gh pr edit --add-label to PR requires write permission to both issues and pull-requests #4631

@mback2k

Description

@mback2k

Not sure if this is the best place to post this issue, it may also be a lack of documentation for the GitHub API or CLI.

Describe the bug

gh pr edit --add-label to PR requires write permission to both issues and pull-requests.

  1. Expected failure without any write permission:
    https://github.com/curl/curl/runs/4021004943?check_suite_focus=true#step:5:13

  2. Unexpected silent failure with write permission to pull-requests, but missing write permission to issues:
    https://github.com/curl/curl/runs/4021113193?check_suite_focus=true#step:5:17
    (mentioned PRs did not get the label via GitHub Actions bot, but it was then later manually added by myself)

  3. Surprising success with both write permissions for pull-requests and issues:
    https://github.com/curl/curl/runs/4027534500?check_suite_focus=true#step:5:13
    (mentioned PR did get the label via GitHub Actions bot)

Local version affected in addition to the version inside the ubuntu-latest GitHub Action image:

gh version 2.2.0 (2021-10-25)
https://github.com/cli/cli/releases/tag/v2.2.0

Steps to reproduce the behavior

Repeat the following steps with the different set of workflow permissions mentioned above:

  1. Add hacktoberfest label to a test repository (can also replace hacktoberfest with hacktobertest or some other test label to avoid actual participation).
  2. Copy this workflow into the test repository (adapt workflow to test label for both the repository and pull-requests if changed in previous step).
  3. Make sure the workflow is present on the default branch on GitHub (adapt workflow to run on pushes to default branch if needed).
  4. Open a new pull-request to the test repository.
  5. Mention the pull-request with a "Closes #prnum" reference on the default branch.

Expected vs actual behavior

I would have expected this to work with just the write permission for pull-requests since a PR is the target of the edit.

Logs

See links to check logs mentioned above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedbugSomething isn't workingplatformProblems with the GitHub platform rather than the CLI clientpriority-3Affects a small number of users or is largely cosmetic

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions