github/github-mcp-server · warning
failed to marshal labels: %w
Error message
failed to marshal labels: %w
What it means
json.Marshal of the labels response map ([]labels, totalCount, has_more) failed. The map holds only GraphQL-derived strings and ints, so a marshal error indicates unsupported values (NaN floats sneaking in) or upstream githubv4 type changes - effectively unreachable in a healthy build.
Source
Thrown at pkg/github/ui_tools.go:175
if !query.Repository.Labels.PageInfo.HasNextPage {
break
}
if page >= uiGetMaxPages {
hasMore = true
break
}
vars["cursor"] = githubv4.NewString(query.Repository.Labels.PageInfo.EndCursor)
}
response := map[string]any{
"labels": labels,
"totalCount": totalCount,
"has_more": hasMore,
}
out, err := json.Marshal(response)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal labels: %w", err)
}
return utils.NewToolResultText(string(out)), nil, nil
}
func uiGetAssignees(ctx context.Context, deps ToolDependencies, args map[string]any, owner string) (*mcp.CallToolResult, any, error) {
repo, err := RequiredParam[string](args, "repo")
if err != nil {
return utils.NewToolResultError(err.Error()), nil, nil
}
client, err := deps.GetClient(ctx)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
}
opts := &github.ListOptions{PerPage: 100}
var allAssignees []*github.UserView on GitHub (pinned to 0ea1f775a7)
Solutions
- Log the underlying marshal error to find the offending field
- Pin the githubv4 version matching this server build
- Add a unit test marshaling a sample labels response map
Defensive patterns
Strategy: fallback
Try / catch
out, err := json.Marshal(response)
if err != nil {
slog.Error("marshal labels failed", "error", err)
out = []byte(`{"labels":[],"totalCount":0,"has_more":false}`)
} Prevention
- Pin githubv4 dependency versions
- Keep the response map to plain JSON-safe types
- Unit-test serialization of every UI tool response shape
When it happens
Trigger: githubv4 dependency drift changing node field types; injecting non-marshalable values into the map in a fork.
Common situations: Version skew after upgrading githubv4; local modifications to uiGetLabels.
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/2ed44a66323eef0b.
Report an issue: GitHub.