actions / github-script

Write workflows scripting the GitHub API in JavaScript
MIT License
4.21k stars 421 forks source link

[BUG]: rest.packages.listPackagesForOrganization return 400 Invalid argument with package type 'container' #449

Closed SteeveGL closed 9 months ago

SteeveGL commented 9 months ago

What happened?

I'm using actions/github-script@v7.0.1 to call github.rest.packages.listPackagesForOrganization. When I'm using it with other package types, I don't have any issue. but 'container' type returns error 400. I expect 200.

I cannot reproduce by using a http call on the api url with a personal token.

...
let packagesResponse;
try {
  packagesResponse = await github.rest.packages.listPackagesForOrganization({
    org: org,
    package_type: 'container'
  });
} catch (error) {
  console.error(`Error fetching packages of type ${packageType}:`, error);
  continue;
}
...

Same result with:

let packagesResponse;
try {
  packagesResponse = await github.request('GET /orgs/{org}/packages', {
    org: org,
    package_type: packageType
  });
} catch (error) {
  console.error(`Error fetching packages of type ${packageType}:`, error);
  continue;
}

https://github.dev/UtopikSandcastle/accesscontrol-api/blob/UtopikSolutions-patch-1/.github/workflows/cleanup.yml

Versions

actions/github-script@v7

Relevant log output

Error fetching packages of type container: RequestError [HttpError]: Invalid argument.
    at /home/runner/work/_actions/actions/github-script/v7.0.1/dist/index.js:9537:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7.0.1/dist/index.js:35424:16), <anonymous>:36:24)
    at async main (/home/runner/work/_actions/actions/github-script/v7.0.1/dist/index.js:35522:20) {
  status: 400,
  response: {
    url: 'https://api.github.com/orgs/UtopikSandcastle/packages?package_type=container&per_page=30',
    status: 400,
    headers: {
      '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',
      'content-length': '134',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Fri, 12 Jan 2024 00:32:41 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      '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': '34C1:75F1:31F4D60:33B551F:65A088A9',
      'x-ratelimit-limit': '1000',
      'x-ratelimit-remaining': '909',
      'x-ratelimit-reset': '1705020148',
Checking package type: npm
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '91',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Invalid argument.',
      documentation_url: 'https://docs.github.com/rest/packages/packages#list-packages-for-an-organization'
    }
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/orgs/UtopikSandcastle/packages?package_type=container&per_page=30',
    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)',
      authorization: 'token [REDACTED]'
    },
    request: {
      agent: [Agent],
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  }
}
SteeveGL commented 9 months ago

Seems GitHub token is still not supported pour container...

https://github.com/orgs/community/discussions/26268#discussioncomment-3251118