Paginate Code Scanning alerts instead of returning only the first page#777
Conversation
GetCodeScanningAlerts made a single ListAlertsForRepo/ListAlertsForOrg call with no pagination and no PerPage override, so GitHub's default page size of 30 applied and any repository/org with more than 30 alerts silently returned only the first 30. Loop over pages using resp.NextPage (PerPage 100), matching how the other paginated queries (e.g. deployments) already work. Fixes grafana#773 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
|
1 similar comment
|
|
|
@Tarasusrus Please sign the CLA |
|
@Tarasusrus Let me know once you sign the CLA so I can make sure that the license/cla check is working |
|
@mattvella07 Signed — The only remaining red check is Everything else — build, docs, and the full Playwright E2E matrix — is green. Ready to merge from my side. Thanks for the review! |
|
@Tarasusrus Thanks! That check is to help us keep track of PRs, so its not required to pass. I'll go head and merge. Thanks for the contribution! |
What this PR does
Fixes #773.
GetCodeScanningAlertsmade a singleListAlertsForRepo/ListAlertsForOrgcall with no pagination loop and noPerPageoverride, so GitHub's default page size of 30 applied. Any repository or organization with more than 30 code scanning alerts silently returned only the first 30, regardless of the true count.Fix
Loop over pages using
resp.NextPagewithPerPage: 100, the same idiom already used by the other paginated queries (e.g.GetAllDeploymentsindeployments.go).ListOptionsis referenced explicitly becauseAlertListOptionsalso embedsListCursorOptions, which would make a barePage/PerPageambiguous.Tests
Extended the code scanning mock client to serve successive pages and added
TestGetCodeScanningAlertsPagination:1, 2, 3in order.Existing single-page tests continue to pass.
go test ./pkg/...is green.