github/github-mcp-server · warning
failed to marshal response: %w
Error message
failed to marshal response: %w
What it means
After fetching and (under lockdown) filtering sub-issues, json.Marshal of the []*github.SubIssue slice failed. These are plain go-github structs whose fields are all stdlib-JSON-safe types, so in production this is nearly unreachable; it fires only with exotic data shapes — a forked go-github with custom MarshalJSON that errors, NaN/Inf values in custom numeric types, or cyclic structures injected by mocks in tests.
Source
Thrown at pkg/github/issues.go:951
}
login := user.GetLogin()
if login == "" {
continue
}
isSafeContent, err := cache.IsSafeContent(ctx, login, owner, repo)
if err != nil {
return utils.NewToolResultError(fmt.Sprintf("failed to check lockdown mode: %v", err)), nil
}
if isSafeContent {
filteredSubIssues = append(filteredSubIssues, subIssue)
}
}
subIssues = filteredSubIssues
}
r, err := json.Marshal(subIssues)
if err != nil {
return nil, fmt.Errorf("failed to marshal response: %w", err)
}
return utils.NewToolResultText(string(r)), nil
}
// GetIssueParent returns the parent issue of the given issue, or a null
// parent when the issue is not a sub-issue. It reads the GraphQL
// Issue.parent field, the upward counterpart to get_sub_issues.
//
// The parent title is always sanitized (it may be cross-repo). Under
// lockdown mode the parent is only returned when its author has push
// access to the parent repo (mirroring GetIssue); otherwise it is omitted.
func GetIssueParent(ctx context.Context, client *githubv4.Client, deps ToolDependencies, owner string, repo string, issueNumber int) (*mcp.CallToolResult, error) {
cache, err := deps.GetRepoAccessCache(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get repo access cache: %w", err)
}
flags := deps.GetFlags(ctx)View on GitHub (pinned to 0ea1f775a7)
Solutions
- Unwrap the error — json.UnsupportedTypeError/UnsupportedValueError names the exact offending type and field path
- If a forked go-github is in use, audit its custom MarshalJSON implementations
- Sanitize non-encodable values (NaN/Inf) before they reach response structs
- Verify go-github version matches the one in go.sum (dependency confusion check)
Defensive patterns
Strategy: try-catch
Type guard
func isMarshalError(err error) bool {
var te *json.UnsupportedTypeError
var ve *json.UnsupportedValueError
return errors.As(err, &te) || errors.As(err, &ve)
} Try / catch
res, err := githubpkg.GetSubIssues(ctx, client, deps, owner, repo, num, pagination)
if err != nil {
var te *json.UnsupportedTypeError
if errors.As(err, &te) {
log.Error("unencodable field in sub-issue payload", "type", te.Type.String(), "path", fmt.Sprint(te.Value))
}
return err
} Prevention
- Pin go-github to the audited version in go.sum
- Round-trip marshal representative API fixtures in unit tests
- Avoid custom marshalers on API response types in forks
- Never inject non-JSON-native values (NaN, chans, cycles) into response structs
When it happens
Trigger: json.Marshal encounters a value it cannot encode: NaN/Inf passed through a custom float type, a type with a MarshalJSON method that itself returns an error, or a reference cycle. The standard github.SubIssue shape cannot produce any of these.
Common situations: Vendored/forked go-github versions adding custom marshalers; test fixtures replacing API structs with cyclic fakes; dependency confusion pulling a different github.com/google/go-github version.
Related errors
- GitHub App authentication and GITHUB_PERSONAL_ACCESS_TOKEN a
- GitHub App ID or client ID is required (GITHUB_APP_ID)
- repo is required
- failed to marshal response: %w
- failed to marshal workflow: %w
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/5810621b5ba07b86.
Report an issue: GitHub.