-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Having ListOptions and ListCursorOptions in AlertListOptions creates ambiguity #3246
Comments
I agree that this is ambiguous, confusing, and unnecessary. Looking at the two endpoints that use these options, both of them take @himazawa - would you like to make a PR, or shall I open this up to other contributors to this repo (or maybe just do this one myself when I get a chance)? |
Yes I can look into it but looks like the issue is bigger since looks like Check this repro:
|
Hmmm... Maybe I'll have to dig through the history of this... It might be a known issue where both are needed. At the very least, we should add a comment that better explains the usage and nuances. |
Yea @gmlewis, There is no way to paginate that endpoint using The doc doesn't seem so clear about it tho. func GetOrgSecurityAlert(org string) {
client := github.NewClient(nil).WithAuthToken(os.Getenv("GH_PAT"))
opts := &github.AlertListOptions{
ListCursorOptions: github.ListCursorOptions{
PerPage: 100,
},
}
ctx := context.Background()
for {
results, resp, err := client.CodeScanning.ListAlertsForOrg(ctx, org, opts)
if err != nil {
log.Fatalln(err)
}
fmt.Println(resp.Cursor, resp.Before, resp.After)
if resp.Before == resp.After {
break
}
opts.ListCursorOptions.After = resp.After
}
} I'm not sure if checking What we could do is:
What do you think about that? |
I think that sounds like a good plan if you can make sure in unit tests that past examples from the discussions in #2511 and #2446 are all taken into account and that we don't further break things. (It's OK if we make a breaking API change to support this, but I'm talking about not further breaking existing functionality, to be clear.) |
I don't think it will break anything, indeed the ambiguity is only trying to call |
Since both ListOptions and ListCursorOptions implements
Page
andPerPage
there is an ambiguity for both fields.go-github/github/code-scanning.go
Line 144 in 90bf432
go-github/github/code-scanning.go
Line 148 in 90bf432
My suggestion would be to add the explicit reference to the struct.
The text was updated successfully, but these errors were encountered: