Skip to content

gh pr list depends on the read permission for Issues #5986

Closed

Description

@r7kamura

Describe the bug

I haven't been able to investigate this in detail, but isn't it strange that the result of the gh pr list command changes depending on the permissions on Issues?

Steps to reproduce the behavior

The following command with almost all permissions will successfully return pull requests data.

$ gh pr list --label foo --json "number" --jq length
42

Expected vs actual behavior

However, when I run the same command on GitHub Action using an access token created by a GitHub App that does not have read permission to Issues (but has read permission to Pull Requests), it always returns an empty array. In the example above, it always returns 0.

image

$ gh pr list --label foo --json "number" --jq length
0

and I gave read permission to Issues and it works as intended.

Logs

image

It's quite difficult to prepare a reproduction environment, and I haven't been able to prepare a good log. Sorry about that.

This is what it looks like when I run the problematic action in my private work repository.

Activity

  1. added
    bug
    on Jul 23, 2022
  2. added
    needs-triage
    on Jul 23, 2022
  3. added
    platform
    and removed
    needs-triage
    on Jul 25, 2022
  4. mislav commented on Jul 25, 2022

    @mislav
    Contributor

    Thank you for reporting! I have reported this on the GitHub platform end since it looks like it is a bug with GitHub Search when invoked through GraphQL API. In the meantime, the workaround is to always give issues: read permissions to tokens that need to operate on Pull Requests.

  5. h4xnoodle commented on Sep 3, 2022

    @h4xnoodle

    This really stumped me for a while, it would be great if the CLI returned an error if the attempt failed instead of just returned a valid value and exit 0

    it was extremely subtle for me. gh pr list returns everything inside the action and gh pr list --json labels works out too, but gh pr list --label <label> returns nothing. so it seems specifically around searching via label.

    A workaround I have is to list them all then use -q with a selection query for my label.

    what I wanted to do: gh pr list --label mylabel --json headRefName what I did to work around: gh pr list --json labels,headRefName -q '.[] | select(if .labels | .[].name == "mylabel" then true else false end) | .headRefName'

  6. mislav commented on Oct 24, 2022

    @mislav
    Contributor

    This should now be fixed on the platform 🎉

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

    blockedbugplatform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions