Skip to content

fix!: Add ListCursorOptions to Enterprise and Org code security configs#3997

Open
maishivamhoo123 wants to merge 2 commits intogoogle:masterfrom
maishivamhoo123:fix-enterprise-codesec-pagination
Open

fix!: Add ListCursorOptions to Enterprise and Org code security configs#3997
maishivamhoo123 wants to merge 2 commits intogoogle:masterfrom
maishivamhoo123:fix-enterprise-codesec-pagination

Conversation

@maishivamhoo123
Copy link
Contributor

This PR updates ListEnterpriseCodeSecurityConfigurationOptions and ListCodeSecurityConfigurationRepositoriesOptions to embed ListCursorOptions.

Changes:

  • Replaced manual pagination fields (Before, After, PerPage) with ListCursorOptions embedding.
    Reason:
    These endpoints support cursor-based pagination. Explicitly embedding ListCursorOptions ensures the library generates the correct Iter methods, preventing infinite loops and aligning with the GitHub API.

Issue Related #3976

Comment on lines -23 to -30
// A cursor, as given in the Link header. If specified, the query only searches for security configurations before this cursor.
Before string `url:"before,omitempty"`

// A cursor, as given in the Link header. If specified, the query only searches for security configurations after this cursor.
After string `url:"after,omitempty"`

// For paginated result sets, the number of results to include per page.
PerPage int `url:"per_page,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis maybe it is better to simply extend the gen-iterators.go to support generating iterator methods from the ListEnterpriseCodeSecurityConfigurationOptions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this kind of breaking change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand, @alexandear - the point of using ListOptions and ListCursorOptions is to standardize the pagination handling. Since this endpoint uses cursor pagination, it makes sense to me to embed ListCursorOptions like we do with the other endpoints that support cursor pagination.
The next release is already going to have a large number of breaking API changes, mostly related to pagination, so I think it is fine to include this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListCursorOptions contains more fields than the GitHub API expects. From a user's perspective, it's better to have a simpler ListEnterpriseCodeSecurityConfigurationOptions with only three fields: before, after, and per_page.

ListCursorOptions:

go-github/github/github.go

Lines 267 to 290 in 1732098

type ListCursorOptions struct {
// For paginated result sets, page of results to retrieve.
Page string `url:"page,omitempty"`
// For paginated result sets, the number of results to include per page.
PerPage int `url:"per_page,omitempty"`
// For paginated result sets, the number of results per page (max 100), starting from the first matching result.
// This parameter must not be used in combination with last.
First int `url:"first,omitempty"`
// For paginated result sets, the number of results per page (max 100), starting from the last matching result.
// This parameter must not be used in combination with first.
Last int `url:"last,omitempty"`
// A cursor, as given in the Link header. If specified, the query only searches for events after this cursor.
After string `url:"after,omitempty"`
// A cursor, as given in the Link header. If specified, the query only searches for events before this cursor.
Before string `url:"before,omitempty"`
// A cursor, as given in the Link header. If specified, the query continues the search using this cursor.
Cursor string `url:"cursor,omitempty"`
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, if we decide to use ListCursorOptions, let's simply inline it instead of ListEnterpriseCodeSecurityConfigurationOptions:

func (s *EnterpriseService) ListCodeSecurityConfigurations(ctx context.Context, enterprise string, opts *ListCursorOptions) ([]*CodeSecurityConfiguration, *Response, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexandear Sir Thank you for the suggestion.

I feel we should keep the wrapper struct as it is, rather than inlining ListCursorOptions.

The reason is that github/gen-iterators.go relies on the wrapper to generate the iterator. Specifically, the hasOptions function iterates over the Embeds list to find a match:
https://github.com/google/go-github/blob/master/github/gen-iterators.go#L177

Since ListCursorOptions defines fields directly and does not embed itself, hasOptions returns false if we use it directly in the function signature. This causes the generator to skip creating the Iter method for this endpoint entirely.

To support inlining, we would likely need to refactor the generator logic itself. Given this, and the benefit of future extensibility, I believe keeping the wrapper struct is the safer approach.

Please let me know if I have misunderstood the logic or if there is a better way to handle this.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.54%. Comparing base (ab5ad47) to head (72b1706).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3997      +/-   ##
==========================================
+ Coverage   93.52%   93.54%   +0.01%     
==========================================
  Files         207      207              
  Lines       17597    17648      +51     
==========================================
+ Hits        16458    16509      +51     
  Misses        938      938              
  Partials      201      201              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis changed the title fix!: Add ListCursorOptions to Enterprise and Org code security configs fix!: Add ListCursorOptions to Enterprise and Org code security configs Feb 12, 2026
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 this pull request may close these issues.

3 participants