github/github-mcp-server · info
failed to marshal advisories: %w
Error message
failed to marshal advisories: %w
What it means
Returned if json.Marshal fails on the global advisories payload. The slice contains only JSON-safe go-github structs, so encoding cannot fail under normal operation; this is defensive dead code. An occurrence would indicate a version mismatch in the go-github types rather than a runtime condition.
Source
Thrown at pkg/github/security_advisories.go:204
}
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 Advisory
// Database (public) but contain externally authored prose
// (untrusted).
result = attachStaticIFCLabel(ctx, deps, result, ifc.LabelGlobalSecurityAdvisory())
return result, nil, nil
},
)
}
func ListRepositorySecurityAdvisories(t translations.TranslationHelperFunc) inventory.ServerTool {
return NewTool(
ToolsetMetadataSecurityAdvisories,
mcp.Tool{
Name: "list_repository_security_advisories",
Description: t("TOOL_LIST_REPOSITORY_SECURITY_ADVISORIES_DESCRIPTION", "List repository security advisories for a GitHub repository."),View on GitHub (pinned to 0ea1f775a7)
Solutions
- No runtime action needed - report upstream if it ever fires
Defensive patterns
Strategy: try-catch
Try / catch
if err != nil && strings.Contains(err.Error(), "failed to marshal advisories") {
// plain-data structs cannot fail to marshal: report upstream
log.Error("impossible marshal failure on advisory list", "err", err)
} Prevention
- No prevention needed - treat as an upstream bug
- Pin go-github versions so struct definitions stay stable
When it happens
Trigger: No realistic API call produces this.
Common situations: Not observed in practice.
Related errors
- failed to marshal alert: %w
- failed to marshal alerts: %w
- GitHub App authentication and GITHUB_PERSONAL_ACCESS_TOKEN a
- GitHub App ID or client ID is required (GITHUB_APP_ID)
- repo is required
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/5528e77fde8641e7.
Report an issue: GitHub.