github/github-mcp-server · error
failed to read response body: %w
Error message
failed to read response body: %w
What it means
list_global_security_advisories received a non-200 response and reading that error body failed. The real status - typically 422 bad filter, 403 rate limit, or 5xx - is masked by this secondary transport failure, so the visible message describes only the failed body read.
Source
Thrown at pkg/github/security_advisories.go:197
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 Advisory
// Database (public) but contain externally authored prose
// (untrusted).
result = attachStaticIFCLabel(ctx, deps, result, ifc.LabelGlobalSecurityAdvisory())
return result, nil, nil
},
)
}View on GitHub (pinned to 0ea1f775a7)
Solutions
- Retry once - usually transient
- If it repeats, review the filter arguments (ecosystem, affects, date ranges) that likely caused the underlying 4xx
- Patch the handler to include resp.StatusCode when the body is unreadable
Example fix
// after
return nil, nil, fmt.Errorf("failed to list advisories: status %d (body unreadable: %w)", resp.StatusCode, err) Defensive patterns
Strategy: retry
Type guard
func isBodyReadFailure(err error) bool {
var netErr net.Error
return errors.As(err, &netErr) || errors.Is(err, io.ErrUnexpectedEOF)
} Try / catch
result, extra, err := callTool(ctx, "list_global_security_advisories", args)
if err != nil && strings.Contains(err.Error(), "failed to read response body") {
result, extra, err = callTool(ctx, "list_global_security_advisories", args)
}
if err != nil {
return fmt.Errorf("advisory listing failed (status masked): %w", err)
} Prevention
- Set deadlines that cover complete error bodies, not just headers
- Retry once on masked-status failures
- Review filter arguments when the error recurs - the hidden status is often 422
When it happens
Trigger: Non-2xx from ListGlobalSecurityAdvisories followed by a connection break or context cancellation while the error body streamed; deadlines expiring just after headers arrive.
Common situations: Marginal networks; hard timeouts in front of the MCP server; rare in stable environments.
Related errors
- failed to read response body: %w
- failed to read response body: %w
- failed to read response body: %w
- failed to read file content: %w
- GitHub App authentication requires a private key: set GITHUB
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/6b6c25e7de5a082b.
Report an issue: GitHub.