Skip to content

Actions: cannot access issue that was added to an org project #3346

@mislav

Description

@mislav

This was reported to us by @skedwards88: accessing or doing an operation on an issue in an Actions workflow can fail with a json error:

gh issue close 123
json: cannot unmarshal number into Go struct field GraphQLError.Errors.Path of type string

It looks like this happen when

  1. The generated GITHUB_TOKEN was used;
  2. The issue was added as a card to an organization project.

Whenever we fetch an issue, we fetch the list of the projects it belongs to. However, if one of these projects is an organization-level project, the generated GITHUB_TOKEN will not have access to read its information since it only has access to the current repository.

I count several bugs here:

  • We over-fetch GraphQL fields. In this case, fetching the list of project for an issue is absolutely not necessary to close an issue. We should instead only fetch the ID of an issue. Avoid over-fetching from the API in pr commands #2849
  • Our GraphQL error-handling mechanism doesn't handle the case when the path property of an error is an array that contains a mix of strings and numbers.
    Path []string
  • We currently don't anticipate that the current token might not have the privileges to read the information about all the projects the issue belongs to. Ideally, we should handle GraphQL errors with path repository.issue.projectCards.nodes[*] as non-fatal and still allow the gh issue command to proceed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions