octokit / octokit.js

The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno.
MIT License
6.84k stars 1k forks source link

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

Closed SteeveGL closed 5 months ago

SteeveGL commented 5 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.

...
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;
}
...

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

Versions

actions/github-script octokit-core.js/5.0.1 Node.js/20.8.1 (linux; x64)

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]
    }
  }
}

Code of Conduct

github-actions[bot] commented 5 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

SteeveGL commented 5 months ago

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

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