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

ListAlertsForOrg options should support cursor pagination #2511

Closed
jporzucek opened this issue Oct 21, 2022 · 7 comments · Fixed by #2512
Closed

ListAlertsForOrg options should support cursor pagination #2511

jporzucek opened this issue Oct 21, 2022 · 7 comments · Fixed by #2512

Comments

@jporzucek
Copy link
Contributor

jporzucek commented Oct 21, 2022

At the moment ListAlertsForOrg function supports only offset (page) pagination while querying REST API https://api.github.com/orgs/ORG/code-scanning/alerts endpoint returns link header with after query parameter. Therefore, the AlertListOptions struct should include ListCursorOptions field.

@gmlewis
Copy link
Collaborator

gmlewis commented Oct 21, 2022

According to the docs here: https://docs.github.com/en/rest/code-scanning#list-code-scanning-alerts-for-an-organization
These endpoints also take a page parameter that it an integer, which is what ListOptions provides.

So unfortunately, this is not a simple replacement, and #2512 would be a breaking API change that would confuse anybody currently using the Page field.

This is going to need some discussion as how to correctly solve this situation.
My initial thought is that we need a third type of ListCursorOptions where Page is an int instead of a string, but am open to other ideas.

ksnip_20221021-072251

@jporzucek
Copy link
Contributor Author

jporzucek commented Oct 21, 2022

But at the same time docs says that both pages and cursors are allowed so isn't ListCursorOptions a natural candidate here? From what I'm seeing ListCursorOptions just extends ListOptions for cursors support.

[edit] I see now, there is string and int difference for page 😞

@jporzucek
Copy link
Contributor Author

jporzucek commented Oct 21, 2022

Did some digging and looks like that the only endpoint in the whole API that accepts page parameter as string is https://docs.github.com/en/enterprise-cloud@latest/rest/teams/team-sync#list-idp-groups-for-an-organization and what's more, it doesn't define a page number but page token (whatever it is).

Therefore, it may make sense to create a new type of ListOptions specifically for that edge case.

Also, page as string is now confusing for all endpoints that accept it as int and use ListCursorOptions type.

@gmlewis
Copy link
Collaborator

gmlewis commented Oct 21, 2022

Yikes! That is a bit disturbing, @jporzucek - thank you for the research!

Would you mind contacting GitHub tech support and explaining the situation to them and see if they have a recommendation for us here in this repo? Feel free to point to this issue that you started.

@AbbanMustafa
Copy link
Contributor

This seems to be a consistent issue across GitHub's API. I had just recently resolved this issue for Secret Scan Alerts #2446

@gmlewis
Copy link
Collaborator

gmlewis commented Oct 25, 2022

This seems to be a consistent issue across GitHub's API. I had just recently resolved this issue for Secret Scan Alerts #2446

Ah, right... thank you for the reminder, @AbbanMustafa !
So we are fine with pulling in both types of list options into the struct where it is necessary.

@jporzucek - could you please do something similar to #2446 ?

@jporzucek
Copy link
Contributor Author

I brought back ListOptions field as suggested together with a test case.

I'm also in touch with GitHub Support so we're sure what type of pagination is indeed supported on that endpoint. Will let you know here once I got a final response.

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

Successfully merging a pull request may close this issue.

3 participants