{"record":{"id":"5810621b5ba07b86","repo":"github/github-mcp-server","slug":"failed-to-marshal-response-w-581062","errorCode":null,"errorMessage":"failed to marshal response: %w","messagePattern":"failed to marshal response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/github/issues.go","lineNumber":951,"sourceCode":"\t\t\t}\n\t\t\tlogin := user.GetLogin()\n\t\t\tif login == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tisSafeContent, err := cache.IsSafeContent(ctx, login, owner, repo)\n\t\t\tif err != nil {\n\t\t\t\treturn utils.NewToolResultError(fmt.Sprintf(\"failed to check lockdown mode: %v\", err)), nil\n\t\t\t}\n\t\t\tif isSafeContent {\n\t\t\t\tfilteredSubIssues = append(filteredSubIssues, subIssue)\n\t\t\t}\n\t\t}\n\t\tsubIssues = filteredSubIssues\n\t}\n\n\tr, err := json.Marshal(subIssues)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal response: %w\", err)\n\t}\n\n\treturn utils.NewToolResultText(string(r)), nil\n}\n\n// GetIssueParent returns the parent issue of the given issue, or a null\n// parent when the issue is not a sub-issue. It reads the GraphQL\n// Issue.parent field, the upward counterpart to get_sub_issues.\n//\n// The parent title is always sanitized (it may be cross-repo). Under\n// lockdown mode the parent is only returned when its author has push\n// access to the parent repo (mirroring GetIssue); otherwise it is omitted.\nfunc GetIssueParent(ctx context.Context, client *githubv4.Client, deps ToolDependencies, owner string, repo string, issueNumber int) (*mcp.CallToolResult, error) {\n\tcache, err := deps.GetRepoAccessCache(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get repo access cache: %w\", err)\n\t}\n\tflags := deps.GetFlags(ctx)","sourceCodeStart":933,"sourceCodeEnd":969,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/issues.go#L933-L969","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isMarshalError(err error) bool {\n    var te *json.UnsupportedTypeError\n    var ve *json.UnsupportedValueError\n    return errors.As(err, &te) || errors.As(err, &ve)\n}","tryCatchPattern":"res, err := githubpkg.GetSubIssues(ctx, client, deps, owner, repo, num, pagination)\nif err != nil {\n    var te *json.UnsupportedTypeError\n    if errors.As(err, &te) {\n        log.Error(\"unencodable field in sub-issue payload\", \"type\", te.Type.String(), \"path\", fmt.Sprint(te.Value))\n    }\n    return err\n}","preventionTips":["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"],"tags":["serialization","json","sub-issues","unreachable"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}