Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Minimal example fails with error #219

Open
1 task done
smjackson opened this issue May 22, 2023 · 5 comments
Open
1 task done

[BUG]: Minimal example fails with error #219

smjackson opened this issue May 22, 2023 · 5 comments
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects

Comments

@smjackson
Copy link

smjackson commented May 22, 2023

What happened?

Creating a new action with the minimal example and variables as listed in the README.md fails with the following error:

Error: Request failed due to following response errors:

  • Variable $owner of type String! was provided invalid value
  • Variable $repo of type String! was provided invalid value

Specifically, code as follows:

on:
    push:
        branches:
            - main

jobs:
  logLatestRelease:
    runs-on: ubuntu-latest
    steps:
      - uses: octokit/graphql-action@v2.x
        id: get_latest_release
        with:
          query: |
            query release($owner:String!,$repo:String!) {
              repository(owner:$owner,name:$repo) {
                releases(first:1) {
                  nodes {
                    name
                    createdAt
                    tagName
                    description
                  }
                }
              }
            }
          variables: |
            owner: ${{ github.event.repository.owner.name }}
            repo: ${{ github.event.repository.name }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - run: "echo 'latest release: ${{ steps.get_latest_release.outputs.data }}'"

Versions

octokit/graphql-action@v2.x

Relevant log output

Run octokit/graphql-action@v2.x
  with:
    query: query release($owner:String!,$repo:String!) {
    repository(owner:$owner,name:$repo) {
      releases(first:1) {
        nodes {
          name
          createdAt
          tagName
          description
        }
      }
    }
  }
  
    variables: owner: myorg
  repo: github-project-playground
  
  env:
    GITHUB_TOKEN: ***
query release($owner:String!,$repo:String!) {
  repository(owner:$owner,name:$repo) {
    releases(first:1) {
      nodes {
        name
        createdAt
        tagName
        description
      }
    }
  }
}

> variables: [object Object]
> mediaType: undefined
Error: Request failed due to following response errors:
 - Variable $owner of type String! was provided invalid value
 - Variable $repo of type String! was provided invalid value

Code of Conduct

  • I agree to follow this project's Code of Conduct
@smjackson smjackson added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels May 22, 2023
@ghost ghost added this to Bugs in JS May 22, 2023
@gr2m
Copy link
Contributor

gr2m commented May 22, 2023

Instead of using variables can you pass owner and repo directly, like in the first README example?

@smjackson
Copy link
Author

That one seems to work.

What would I do if I needed to pass other variables than just owner and repo to my query? Mirror the first example and just add more properties?

@gr2m
Copy link
Contributor

gr2m commented May 24, 2023

just add more properties

yes, exactly. It mirrors the API of @octokit/graphql:
https://github.com/octokit/graphql.js#variables

The support for variables was added via #209, I'm not sure why it's not working. We do support object variables in octokit/request-action (see complex example), I don't have the time to investigate what's different right now unfortunately, but happy to review a PR if you or anyone is interested in investigating

@zliang-akamai
Copy link

Got a same issue

@meyersbs
Copy link

meyersbs commented Jun 26, 2023

Same error for me:

- name: Query for Text
  uses: octokit/graphql-action@v2.x
  id: issue-text
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    query: |
      query issuetext($owner:String!,$repo:String!,$number:Int!) {
        repository(owner:$owner,name:$repo) {
          thisIssue: issue(number:$number) {
            title
            bodyText
            comments(first:10) {
              edges {
                node {
                  bodyText
                }
              }
            }
          }
        }
      }
  variables: |
    number: ${{ github.event.issue.number }}
    repo: ${{ github.event.repository.name }}
    owner: ${{ github.event.repository.owner.name }}
Error: Request failed due to following response errors:
 - Variable $owner of type String! was provided invalid value
 - Variable $repo of type String! was provided invalid value
 - Variable $number of type Int! was provided invalid value

Using without variables works, except for owner. These both fail:

  • owner: ${{ github.event.repository.owner.name }}
  • owner: ${{ github.event.repository_owner }}

@wolfy1339 wolfy1339 added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
JS
  
Bugs
Development

No branches or pull requests

5 participants