elastic / snyk-github-issue-creator

CLI tool for creating GitHub issues from Snyk project issues
5 stars 6 forks source link

Octokit API pagination results in invalid request headers in node >= 18 #29

Closed jeramysoucy closed 9 months ago

jeramysoucy commented 9 months ago

Version: 2.1.2

Due to some changes in node 18 - the introduction of a default global fetch API, one of the calls we make to octokit.paginate results in generating invalid request headers when runnign with node >= 18. e.g.

https://api.github.com/repos/elastic/security/labels?per_page=100&status=200&data=[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]%2C[object Object]"

As we use octokit.paginate successfully with a raw request URL elsewhere, the simplest solution is to replace the octokit API call within the paginate with the raw GitHub API URL.

From:

const responseData = await octokit.paginate(
    await client.issues.listLabelsForRepo({
      owner: ghOwner,
      repo: ghRepo,
      per_page: 100
    }),
    (response) => response.data
  )

To:

const responseData = await octokit.paginate(`GET /repos/${conf.ghOwner}/${conf.ghRepo}/labels?per_page=100`)