Summary
The Code Scanning query type only returns the first 30 alerts regardless of how many exist in the repository or
organization. This is because the GetCodeScanningAlerts function makes a single API call with no pagination loop and no
PerPage override (so GitHub's default of 30 applies).
Steps to Reproduce
- Configure a GitHub datasource panel with Query Type = Code Scanning
- Set State =
open on a repository with more than 30 alerts
- Observe that exactly 30 results are returned regardless of the true count
Expected Behavior
All matching alerts are returned, consistent with how other query types (e.g. Dependabot vulnerabilities) paginate through
results.
Actual Behavior
Root Cause
In pkg/github/codescanning.go, GetCodeScanningAlerts calls ListAlertsForRepo / ListAlertsForOrg once with no
ListOptions.PerPage set and no loop to fetch subsequent pages:
alerts, _, err = c.ListAlertsForRepo(
context,
opt.Owner,
opt.Repository,
&googlegithub.AlertListOptions{
State: opt.State,
Ref: opt.Ref,
},
)
By contrast, the Dependabot vulnerabilities implementation correctly uses a for loop with PageInfo.HasNextPage to paginate
all results.
This was noted as a known gap in the original draft PR #377 ("fetch more than just the first 100") but was not addressed
before the feature shipped in #462.
Environment
- Plugin version: v2.1.6 through v2.8.0 (latest) — all affected
- Grafana version: tested on 11.4.0
- Affects both repo-level and org-level Code Scanning queries
Suggested Fix
Add a pagination loop to GetCodeScanningAlerts using ListOptions.Page / Response.NextPage, following the same pattern used
in the Dependabot vulnerabilities implementation.
Summary
The Code Scanning query type only returns the first 30 alerts regardless of how many exist in the repository or
organization. This is because the
GetCodeScanningAlertsfunction makes a single API call with no pagination loop and noPerPageoverride (so GitHub's default of 30 applies).Steps to Reproduce
openon a repository with more than 30 alertsExpected Behavior
All matching alerts are returned, consistent with how other query types (e.g. Dependabot vulnerabilities) paginate through
results.
Actual Behavior
Root Cause
In
pkg/github/codescanning.go,GetCodeScanningAlertscallsListAlertsForRepo/ListAlertsForOrgonce with noListOptions.PerPageset and no loop to fetch subsequent pages: