github/github-mcp-server · error
failed to list global security advisories: %w
Error message
failed to list global security advisories: %w
What it means
client.SecurityAdvisories.ListGlobalSecurityAdvisories returned a non-nil error. Unlike sibling handlers, this one returns the raw wrapped error instead of ghErrors.NewGitHubAPIErrorResponse, so both transport failures and GitHub API errors surface here together; go-github's *github.ErrorResponse inside carries the status and message. Common causes: 422 invalid filter values, 403 rate limit exhausted, and DNS/TLS failures to the API host.
Source
Thrown at pkg/github/security_advisories.go:190
opts.IsWithdrawn = &isWithdrawn
}
if affects != "" {
opts.Affects = &affects
}
if published != "" {
opts.Published = &published
}
if updated != "" {
opts.Updated = &updated
}
if modified != "" {
opts.Modified = &modified
}
advisories, resp, err := client.SecurityAdvisories.ListGlobalSecurityAdvisories(ctx, opts)
if err != nil {
return nil, nil, fmt.Errorf("failed to list global security advisories: %w", err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, nil, fmt.Errorf("failed to read response body: %w", err)
}
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to list advisories", resp, body), nil, nil
}
r, err := json.Marshal(advisories)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal advisories: %w", err)
}
result := utils.NewToolResultText(string(r))
// Global advisories come from the world-readable GitHub AdvisoryView on GitHub (pinned to 0ea1f775a7)
Solutions
- Unwrap with errors.As(err, *github.ErrorResponse) and read Message/Status: 422 means fix the offending filter argument
- On 403/429, wait until x-ratelimit-reset and retry with fewer, larger pages
- On transport errors, verify connectivity and TLS to the configured API host
- Code improvement: route API errors through NewGitHubAPIErrorResponse for consistent, actionable messages
Example fix
// before
advisories, resp, err := client.SecurityAdvisories.ListGlobalSecurityAdvisories(ctx, opts)
if err != nil {
return nil, nil, fmt.Errorf("failed to list global security advisories: %w", err)
}
// after - keep API errors structured, wrap only transport errors
var ghErr *github.ErrorResponse
if errors.As(err, &ghErr) {
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to list global security advisories", resp, err), nil, nil
}
return nil, nil, fmt.Errorf("failed to list global security advisories: %w", err) Defensive patterns
Strategy: retry
Validate before calling
// Validate filter enums/dates before calling the tool
validEcosystems := map[string]bool{"pip": true, "npm": true, "maven": true, "rubygems": true,
"nuget": true, "composer": true, "go": true, "rust": true, "erlang": true,
"actions": true, "pub": true, "other": true}
if eco != "" && !validEcosystems[eco] {
return fmt.Errorf("ecosystem %q is not one of the allowed values", eco)
}
for _, d := range []string{published, updated, modified} {
if d != "" && !validDateOrRange(d) {
return fmt.Errorf("date filter %q must be an ISO 8601 date or range", d)
}
} Type guard
func isGitHubAPIError(err error) (*github.ErrorResponse, bool) {
var ghErr *github.ErrorResponse
if errors.As(err, &ghErr) {
return ghErr, true
}
return nil, false
}
func isRetryableListErr(err error) bool {
ghErr, ok := isGitHubAPIError(err)
if !ok {
var netErr net.Error
return errors.As(err, &netErr) // transport: retry
}
return ghErr.Response != nil &&
(ghErr.Response.StatusCode == 429 || ghErr.Response.StatusCode >= 500)
} Try / catch
advisories, resp, err := client.SecurityAdvisories.ListGlobalSecurityAdvisories(ctx, opts)
if err != nil {
if ghErr, ok := isGitHubAPIError(err); ok {
if ghErr.Response.StatusCode == 422 {
return nil, fmt.Errorf("invalid advisory filter: %s", ghErr.Message) // fix arguments, do not retry
}
if isRetryableListErr(err) {
time.Sleep(backoff) // 429/5xx: retry with jitter
return listAgain(ctx, opts)
}
}
return nil, fmt.Errorf("failed to list global security advisories: %w", err)
} Prevention
- Pass only documented enum values for ecosystem/severity/type and ISO 8601 dates for date filters
- Check rate-limit headroom (x-ratelimit-remaining) before each page fetch
- Classify *github.ErrorResponse before retrying: 4xx means fix arguments, only 429/5xx/transport retry
When it happens
Trigger: Invalid `ecosystem` or `affects` filter strings (422 Unprocessable Entity); primary rate limit exhausted (403 with x-ratelimit-remaining: 0); malformed date ranges in published/updated/modified; network-level failures reaching api.github.com.
Common situations: Passing an ecosystem not in the allowed enum; tight pagination loops ignoring rate-limit headers; egress proxies blocking or intercepting api.github.com TLS.
Related errors
- failed to list repository security advisories: %w
- failed to fetch raw content: %s
- failed to get repositories
- failed to get issue ID: %w
- each issue_fields item must be an object
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/90f817853d0a9014.
Report an issue: GitHub.