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]: auto pagination is not working for listPackagesForOrganization #2400

Open
1 task done
klick-jchong opened this issue Feb 21, 2023 · 2 comments
Open
1 task done
Labels
Status: Needs Info Full requirements are not yet known, so implementation should not be started Type: Bug Something isn't working as documented
Projects

Comments

@klick-jchong
Copy link

What happened?

Trying to use octokit.paginate with octokit.rest.packages.listPackagesForOrganization to return all results.
Example:

const packages = await octokit.paginate(octokit.rest.packages.listPackagesForOrganization, {
    org: '<org>',
    package_type: 'npm',
});

I have provided personal access token with follow scope: read:packages, repo, user:email

Expect: Return all packages for given organization (more than 30 results)
Actual: Only returns the first page results limited to the default page size of 30

  • Note: testing with octokit.rest.repos.listForOrg seems to work fine

Versions

Octokit.js v2.0.14, Node v16.18.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@klick-jchong klick-jchong added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Feb 21, 2023
@ghost ghost added this to Bugs in JS Feb 21, 2023
@kfcampbell kfcampbell added Status: Needs Info Full requirements are not yet known, so implementation should not be started Priority: Normal and removed Status: Triage This is being looked at and prioritized labels Feb 28, 2023
@kfcampbell
Copy link
Member

Are you using the plugin-paginate-rest package when doing so?

@klick-jchong
Copy link
Author

klick-jchong commented Feb 28, 2023

I didn't know you needed that, I assume that comes when you install the full octokit module? eg.

// npm install octokit
const { Octokit } = require('octokit');
const octokit = new Octokit({ auth: "<token>" });

const packages = await octokit.paginate(octokit.rest.packages.listPackagesForOrganization, {
    org: '<org>',
    package_type: 'npm',
});

But even after switching to use the plugin like so, it still is only return the default length (30). My workaround right now is to do the pagination manually via loop, but I assume the paginate helper so suppose to help with that.

// npm install @octokit/core
// npm install @octokit/plugin-paginate-rest
const { Octokit } = require('@octokit/core');
const { paginateRest } = require('@octokit/plugin-paginate-rest');
const MyOctokit = Octokit.plugin(paginateRest);
const octokit = new MyOctokit({ auth: "<token>" });

const packages = await octokit.paginate('GET /orgs/{org}/packages', {
    org: '<org>',
    package_type: 'npm',
});
console.log(packages.length) // returns first 30, even though I expect it to return all

As I noted above, the paginate helper does seem to work with the octokit.rest.repos.listForOrg endpoint just not the octokit.rest.packages.listPackagesForOrganization endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Info Full requirements are not yet known, so implementation should not be started Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
JS
  
Bugs
Development

No branches or pull requests

3 participants