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

Regression with v7 when trying to iterate over pull requests. #448

Open
Miepee opened this issue Jan 11, 2024 · 4 comments
Open

Regression with v7 when trying to iterate over pull requests. #448

Miepee opened this issue Jan 11, 2024 · 4 comments

Comments

@Miepee
Copy link

Miepee commented Jan 11, 2024

Describe the bug
When trying to iterate over pull requests with gh-script v7, it throws. This did not happen with v6.

To Reproduce
Steps to reproduce the behavior:

  1. Use the following workflow file:
name: Test
on:
  workflow_dispatch:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            const {owner, repo} = context.repo;
            await (async () =>
            {
              const pulls = await github.rest.pulls.list({owner, repo});
              for await (const {data} of github.paginate.iterator(pulls))
              {
                console.log(`throws before reaching this :(`)
              }
            })();
  1. Run it manually.

Expected behavior
The runner should not throw, and the log statement should get printed.

Current behaviour
The runner throws. Stacktrace:

RequestError [HttpError]: fetch failed
Error: Unhandled error: HttpError: fetch failed
    at /home/runner/work/_actions/actions/github-script/v7/dist/index.js:9561:11
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.next (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:6790:28)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35424:16), <anonymous>:7:25)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35424:16), <anonymous>:4:22)
    at async main (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35522:20) {
  status: 500,
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/Miepee/UndertaleModTool/pulls?status=200&data=%5Bobject%20Object%5D',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script octokit-core.js/5.0.1 Node.js/20.8.1 (linux; x64)',
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'cache-control': 'private, max-age=60, s-maxage=60',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 11 Jan 2024 23:12:31 GMT',
      etag: 'W/"1165e356503087f242702ad9929ff805d799a1c781f263c5403dfdc189df3eee"',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'github.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'transfer-encoding': 'chunked',
      vary: 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-github-permissions': 'pull_requests=read',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '3889:755A:50E4AD4:A717D92:65A075DE',
      'x-ratelimit-limit': '1000',
      'x-ratelimit-remaining': '997',
      'x-ratelimit-reset': '1705018126',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '3',
      'x-xss-protection': '0',
      authorization: 'token [REDACTED]'
    },
    request: {
      agent: [Agent],
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  }
}
@markmssd
Copy link

We're having the same issue! @Miepee did you find a solution yet?

@Miepee
Copy link
Author

Miepee commented Jan 30, 2024

Not really. I just downgraded to v6.

kasper93 added a commit to kasper93/mpv that referenced this issue Feb 3, 2024
There is an upstream regression in v7. Use v6 until Node 16 is still
available.

See: actions/github-script#448
sfan5 pushed a commit to mpv-player/mpv that referenced this issue Feb 5, 2024
There is an upstream regression in v7. Use v6 until Node 16 is still
available.

See: actions/github-script#448
@acgoldma
Copy link

Not sure if it will work for you, but I found that adding .endpoint.merge after the list call seems to work for my script:

  console.log('Getting Pull Request Commits:')
- const commits = await github.rest.pulls.listCommits({
+ const commits = await github.rest.pulls.listCommits.endpoint.merge({
    owner: context.repo.owner,
    repo: context.repo.repo,
    pull_number: ${{ github.event.number }}
  })

From what I can find, this was actually the method we should use. See this example: https://github.com/marketplace/actions/github-script#welcome-a-first-time-contributor

xrun1 pushed a commit to xrun1/mpv-svp-fix that referenced this issue Mar 12, 2024
There is an upstream regression in v7. Use v6 until Node 16 is still
available.

See: actions/github-script#448
@sndrtj
Copy link

sndrtj commented Jun 26, 2024

I am too seeing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants