github/github-mcp-server · info
failed to marshal label: %w
Error message
failed to marshal label: %w
What it means
The get_label tool failed to JSON-encode the label map built from GraphQL results (id, name, color, description — all strings). Marshal errors are effectively impossible for this shape; the guard exists for safety and signals an internal serialization bug if ever hit.
Source
Thrown at pkg/github/labels.go:111
if err := client.Query(ctx, &query, vars); err != nil {
return ghErrors.NewGitHubGraphQLErrorResponse(ctx, "Failed to find label", err), nil, nil
}
if query.Repository.Label.Name == "" {
return utils.NewToolResultError(fmt.Sprintf("label '%s' not found in %s/%s", name, owner, repo)), nil, nil
}
label := map[string]any{
"id": fmt.Sprintf("%v", query.Repository.Label.ID),
"name": string(query.Repository.Label.Name),
"color": string(query.Repository.Label.Color),
"description": string(query.Repository.Label.Description),
}
out, err := json.Marshal(label)
if err != nil {
return nil, nil, fmt.Errorf("failed to marshal label: %w", err)
}
result := utils.NewToolResultText(string(out))
// Labels are structural repo metadata defined by collaborators
// (trusted); confidentiality follows repo visibility.
result = attachRepoVisibilityIFCLabelLazy(ctx, deps, owner, repo, result, ifc.LabelRepoMetadata)
return result, nil, nil
},
)
}
// GetLabelForLabelsToolset returns the same GetLabel tool but registered in the labels toolset.
// This provides conformance with the original behavior where get_label was in both toolsets.
func GetLabelForLabelsToolset(t translations.TranslationHelperFunc) inventory.ServerTool {
tool := GetLabel(t)
tool.Toolset = ToolsetLabels
return tool
}View on GitHub (pinned to 0ea1f775a7)
Solutions
- Treat as an internal bug: report the github-mcp-server version and label data involved
- Retry once to rule out a transient anomaly; the label query itself already succeeded
Defensive patterns
Strategy: try-catch
Try / catch
if err != nil && strings.Contains(err.Error(), "failed to marshal label") {
// Internal serialization bug; the label lookup succeeded. File an issue with the version.
} Prevention
- Pin server versions and watch the changelog for label response changes
- Log full error context when this fires to help maintainers reproduce
When it happens
Trigger: Not reproducible through the API with the current string-only map; would require the map values to become unsupported types via a code change.
Common situations: Essentially never seen; if reported, it follows a server modification of the label map structure.
Related errors
- failed to marshal labels: %w
- 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
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/a8212b797599563f.
Report an issue: GitHub.