Skip to content

[BUG]: Different result from a graphql postman request than from a github action/ github explorer graphql #276

@MatthieuGomes

Description

@MatthieuGomes

What happened?

I'm trying to get (not only, but that's part of the process) the number of the project associated with the repository from which pull request occurs. To do so, I found out that I need to use graphql requests. So I tested my queries first on Postman... And I happily found a way (yay). But, when I try to get the same result from github actions or explorer, the result is always empty on the fields that matters in this discussion and it's driving me crazy.

The repository is part of an organization but :

  1. No problem in postman
  2. A get all the informations I need EXCEPT the things about the ProjectsV2's nodes !

Here's the query

query ($repo: String!, $organisation: String!, $pull_request_number: Int!) {
              organization(login: $organisation) {
                repository(name: $repo, followRenames: true) {
                  pullRequest(number: $pull_request_number) {
                    body
                    commits(first: 100) {
                      nodes {
                        commit {
                          message
                        }
                      }
                    }
                  }
                  projectsV2(first: 1) {
                      totalCount
                      nodes {
                        number
                      }
                  }
                  recentProjects(first: 10) {
                    nodes {
                      number
                      title
                    }
                  }
                }
              }
            }

Here is the yaml for the github actions

ame: AutoMoveTickets

on:
  pull_request:
    types: [opened,reopened]

env: 
  repo: ${{ github.repository }}
  organisation: ${{ github.repository_owner }}
  pull_request_number: ${{ github.event.number}}

jobs:

  move_mentionned_tickets:
    runs-on: ubuntu-latest
    steps:
      - name: Get Issues Cited of PR 1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        id: get_infos
        uses: octokit/[email protected]
        with:
          query: |
            query ($repo: String!, $organisation: String!, $pull_request_number: Int!) {
              organization(login: $organisation) {
                repository(name: $repo, followRenames: true) {
                  pullRequest(number: $pull_request_number) {
                    body
                    commits(first: 100) {
                      nodes {
                        commit {
                          message
                        }
                      }
                    }
                  }
                  projectsV2(first: 1) {
                      totalCount
                      nodes {
                        number
                      }
                  }
                }
              }
            }
          variables: |
            repo: ${{ github.event.repository.name }}
            organisation : ${{ github.repository_owner }}
            pull_request_number : ${{ github.event.number }}
      - run : "echo ${{ steps.get_infos.outputs.data }}"

(in case you wonder : it's just for test currently and the echo doesnt work BUT i can read the object supposed to be echoed in the log error, so it's fine ^^)

Then, here is the result from such command with a PAT with Postman

{
    "data": {
        "organization": {
            "repository": {
                "pullRequest": {
                    "body": "",
                    "commits": {
                        "nodes": [
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Update auto_move_tickets.yml"
                                }
                            },
                            {
                                "commit": {
                                    "message": "nouveau test"
                                }
                            },
                            {
                                "commit": {
                                    "message": "correction"
                                }
                            },
                            {
                                "commit": {
                                    "message": "re correction?"
                                }
                            },
                            {
                                "commit": {
                                    "message": "re correction encore ?"
                                }
                            },
                            {
                                "commit": {
                                    "message": "test"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Retest"
                                }
                            },
                            {
                                "commit": {
                                    "message": "re"
                                }
                            },
                            {
                                "commit": {
                                    "message": "re correction"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Nouvelle correction"
                                }
                            },
                            {
                                "commit": {
                                    "message": "Nouvelles datas à lire"
                                }
                            },
                            {
                                "commit": {
                                    "message": "rerererere"
                                }
                            },
                            {
                                "commit": {
                                    "message": "rerererererere"
                                }
                            },
                            {
                                "commit": {
                                    "message": "nouvelles infos"
                                }
                            }
                        ]
                    }
                },
                "projectsV2": {
                    "totalCount": 1,
                    "nodes": [
                        {
                            "number": 7
                        }
                    ]
                }
            }
        }
    }
}

And there is the result from github action using the token generated by github action ITSELF.

"data":{
  "organization": {
      "repository": {
        "pullRequest": {
          "body": "",
          "commits": {
            "nodes": [
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "Update auto_move_tickets.yml"
                }
              },
              {
                "commit": {
                  "message": "nouveau test"
                }
              },
              {
                "commit": {
                  "message": "correction"
                }
              },
              {
                "commit": {
                  "message": "re correction?"
                }
              },
              {
                "commit": {
                  "message": "re correction encore ?"
                }
              },
              {
                "commit": {
                  "message": "test"
                }
              },
              {
                "commit": {
                  "message": "Retest"
                }
              },
              {
                "commit": {
                  "message": "re"
                }
              },
              {
                "commit": {
                  "message": "re correction"
                }
              },
              {
                "commit": {
                  "message": "Nouvelle correction"
                }
              },
              {
                "commit": {
                  "message": "Nouvelles datas à lire"
                }
              },
              {
                "commit": {
                  "message": "rerererere"
                }
              },
              {
                "commit": {
                  "message": "rerererererere"
                }
              },
              {
                "commit": {
                  "message": "nouvelles infos"
                }
              }
            ]
          }
        },
        "projectsV2": {
          "totalCount": 0,
          "nodes": []
        }
      }
    }
  }

And I have the same problem with github explorer...

Can someone help ? T.T

Versions

2.0.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    🔥 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions