github/github-mcp-server · info
failed to marshal alerts: %w
Error message
failed to marshal alerts: %w
What it means
Returned if json.Marshal fails on the []*github.SecretScanningAlert slice. Slices of plain data structs marshal without error, so this branch is defensive dead code, same as the single-alert marshal error. An actual occurrence would point to an incompatible go-github type change, not usage.
Source
Thrown at pkg/github/secret_scanning.go:205
return ghErrors.NewGitHubAPIErrorResponse(ctx,
fmt.Sprintf("failed to list alerts for repository '%s/%s'", owner, repo),
resp,
err,
), nil, nil
}
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 alerts", resp, body), nil, nil
}
r, err := json.Marshal(alerts)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal alerts: %w", err)
}
result := utils.NewToolResultText(string(r))
// Secret scanning alerts are access-restricted regardless of repo
// visibility and surface the matched secret material itself, so the
// label is always private-untrusted.
result = attachStaticIFCLabel(ctx, deps, result, ifc.LabelSecurityAlert())
return result, nil, nil
},
)
}
View on GitHub (pinned to 0ea1f775a7)
Solutions
- No runtime action needed - report upstream if it ever fires, including the go-github version
Defensive patterns
Strategy: try-catch
Try / catch
if err != nil && strings.Contains(err.Error(), "failed to marshal alerts") {
// not reachable with JSON-safe go-github structs: treat as upstream bug
log.Error("impossible marshal failure on SecretScanningAlert list", "err", err)
} Prevention
- No prevention needed - occurrence indicates an upstream type change
- Pin the go-github module version to avoid silent struct drift
When it happens
Trigger: No realistic API call produces this; the payload is a slice of JSON-safe structs.
Common situations: Not observed in practice.
Related errors
- failed to marshal alert: %w
- failed to marshal advisories: %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/7bf1c41e12e4d454.
Report an issue: GitHub.