-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
While trying new Iter when i run client.Users.ListAllIter it went into infinite loop, I found out that client.Users.ListAll doesn't support Page based pagination. so i decide to find if there exist more functions with similar or some sort of problems.
Here are my findings -
UsersService.ListAlldon't havepageacc to docs if you run ListAllIter it will go in infinite loop since its pagination is powered exclusively by the since parameter.
Lines 224 to 227 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/users/users#list-users // //meta:operation GET /users func (s *UsersService) ListAll(ctx context.Context, opts *UserListOptions) ([]*User, *Response, error) {
Solution : ReplacingUserListOptions.ListOptionswithUserListOptions.PerPagewhich will also result in removal of ListAllIter
PackageGetAllVersionshandles two endpoints one of them doesn't support pagination acc to docs also for some reason it's Iter dosen't generated maybe because it dose not containListas prefix.
go-github/github/users_packages.go
Lines 130 to 139 in c8fd3f7
// PackageGetAllVersions gets all versions of a package for a user. Passing the empty string for "user" will // get versions for the authenticated user. // // GitHub API docs: https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-a-user // // GitHub API docs: https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-the-authenticated-user // //meta:operation GET /user/packages/{package_type}/{package_name}/versions //meta:operation GET /users/{username}/packages/{package_type}/{package_name}/versions func (s *UsersService) PackageGetAllVersions(ctx context.Context, user, packageType, packageName string, opts *PackageListOptions) ([]*PackageVersion, *Response, error) {
Solution : Dividing PackageGetAllVersions into two separate functions, if Iter is required then addListto prefix of new function
SubIssueService.ListByIssuedosen't support cursor based pagination acc to docs
Lines 71 to 74 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/issues/sub-issues#list-sub-issues // //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues func (s *SubIssueService) ListByIssue(ctx context.Context, owner, repo string, issueNumber int64, opts *IssueListOptions) ([]*SubIssue, *Response, error) {
Solution : RemoveIssueListOptions.ListCursorOptions
RepositoriesService.ListAllTopicsalso support pagination acc to docs.
Lines 1928 to 1931 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/repos/repos#get-all-repository-topics // //meta:operation GET /repos/{owner}/{repo}/topics func (s *RepositoriesService) ListAllTopics(ctx context.Context, owner, repo string) ([]string, *Response, error) {
Solution : Add ListOptions
RepositoriesService.ListCustomDeploymentRuleIntegrationsalso support pagination acc to docs.
btw its Iter will not generate because it doesn't return []*T kind of result
go-github/github/repos_deployment_protection_rules.go
Lines 92 to 95 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/deployments/protection-rules#list-custom-deployment-rule-integrations-available-for-an-environment // //meta:operation GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps func (s *RepositoriesService) ListCustomDeploymentRuleIntegrations(ctx context.Context, owner, repo, environment string) (*ListCustomDeploymentRuleIntegrationsResponse, *Response, error) {
Solution : Add ListOptions
RepositoriesService.ListDeploymentBranchPoliciesalso support pagination acc to docs.
btw its Iter will not generate because it doesn't return []*T kind of result
go-github/github/repos_deployment_branch_policies.go
Lines 35 to 38 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/deployments/branch-policies#list-deployment-branch-policies // //meta:operation GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies func (s *RepositoriesService) ListDeploymentBranchPolicies(ctx context.Context, owner, repo, environment string) (*DeploymentBranchPolicyResponse, *Response, error) {
Solution : Add ListOptions
RepositoriesService.ListAutolinksdosen't support pagination acc to docs.
go-github/github/repos_autolinks.go
Lines 31 to 34 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/repos/autolinks#get-all-autolinks-of-a-repository // //meta:operation GET /repos/{owner}/{repo}/autolinks func (s *RepositoriesService) ListAutolinks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Autolink, *Response, error) {
Solution : Remove ListOptions
PullRequestsService.ListReviewersdosen't support pagination acc to docs.
go-github/github/pulls_reviewers.go
Lines 56 to 59 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/pulls/review-requests#get-all-requested-reviewers-for-a-pull-request // //meta:operation GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo string, number int, opts *ListOptions) (*Reviewers, *Response, error) {
Solution : Remove ListOptions
OrganizationsService.ListAlldon't havepageacc to docs if you run ListAllIter it will go in infinite loop since its pagination is powered exclusively by the since parameter.
Lines 171 to 174 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/orgs/orgs#list-organizations // //meta:operation GET /organizations func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error) {
Solution : ReplacingOrganizationsListOptions.ListOptionswithUserListOptions.PerPagewhich will also result in removal of ListAllIter
OrganizationsService.ListCodeSecurityConfigurationsdocs andOrganizationsService.ListCodeSecurityConfigurationRepositoriesdocs support cursor pagination but its option are not properly made so Iter is missing for it.
go-github/github/orgs_codesecurity_configurations.go
Lines 145 to 148 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-code-security-configurations-for-an-organization // //meta:operation GET /orgs/{org}/code-security/configurations func (s *OrganizationsService) ListCodeSecurityConfigurations(ctx context.Context, org string, opts *ListOrgCodeSecurityConfigurationOptions) ([]*CodeSecurityConfiguration, *Response, error) {
go-github/github/orgs_codesecurity_configurations.go
Lines 338 to 341 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-repositories-associated-with-a-code-security-configuration // //meta:operation GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories func (s *OrganizationsService) ListCodeSecurityConfigurationRepositories(ctx context.Context, org string, configurationID int64, opts *ListCodeSecurityConfigurationRepositoriesOptions) ([]*RepositoryAttachment, *Response, error) {
Solution : AddListCursorOptionstoListCodeSecurityConfigurationRepositoriesOptionsandListOrgCodeSecurityConfigurationOptions
LicensesService.Listsupport pagination acc to docs.
Lines 63 to 66 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses // //meta:operation GET /licenses func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) {
Solution : Add support for ListOptions
IssuesService.Listdocs ,IssuesService.ListByOrgdocs andIssuesService.ListByRepodocs only suppost normal pagination not cursor.
Lines 162 to 168 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/issues/issues#list-issues-assigned-to-the-authenticated-user // // GitHub API docs: https://docs.github.com/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user // //meta:operation GET /issues //meta:operation GET /user/issues func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) {
Lines 257 to 260 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/issues/issues#list-repository-issues // //meta:operation GET /repos/{owner}/{repo}/issues func (s *IssuesService) ListByRepo(ctx context.Context, owner, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error) {
Lines 181 to 184 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user // //meta:operation GET /orgs/{org}/issues func (s *IssuesService) ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) {
Solution : Remove ListCursorOptions
EnterpriseService.ListCodeSecurityConfigurationsdocs andEnterpriseService.ListCodeSecurityConfigurationRepositoriesdocs support cursor pagination but its option are not properly made so Iter is missing for it.
go-github/github/enterprise_codesecurity_configurations.go
Lines 35 to 38 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-code-security-configurations-for-an-enterprise // //meta:operation GET /enterprises/{enterprise}/code-security/configurations func (s *EnterpriseService) ListCodeSecurityConfigurations(ctx context.Context, enterprise string, opts *ListEnterpriseCodeSecurityConfigurationOptions) ([]*CodeSecurityConfiguration, *Response, error) {
go-github/github/enterprise_codesecurity_configurations.go
Lines 212 to 215 in c8fd3f7
// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-repositories-associated-with-an-enterprise-code-security-configuration // //meta:operation GET /enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories func (s *EnterpriseService) ListCodeSecurityConfigurationRepositories(ctx context.Context, enterprise string, configurationID int64, opts *ListCodeSecurityConfigurationRepositoriesOptions) ([]*RepositoryAttachment, *Response, error) {
Solution : AddListCursorOptionstoListCodeSecurityConfigurationRepositoriesOptionsandListEnterpriseCodeSecurityConfigurationOptions
It take so much time to find and write all these 😵