{"record":{"id":"d8ffde68b61c7305","repo":"github/github-mcp-server","slug":"failed-to-marshal-response-w-d8ffde","errorCode":null,"errorMessage":"failed to marshal response: %w","messagePattern":"failed to marshal response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/github/projects.go","lineNumber":1109,"sourceCode":"\n\t// For specified owner_type, process normally\n\tif ownerType != \"\" {\n\t\tdefer func() { _ = resp.Body.Close() }()\n\n\t\tfor _, project := range projects {\n\t\t\tmp := convertToMinimalProject(project)\n\t\t\tmp.OwnerType = ownerType\n\t\t\tminimalProjects = append(minimalProjects, *mp)\n\t\t}\n\n\t\tresponse := map[string]any{\n\t\t\t\"projects\": minimalProjects,\n\t\t\t\"pageInfo\": buildPageInfo(resp),\n\t\t}\n\n\t\tr, err := json.Marshal(response)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, fmt.Errorf(\"failed to marshal response: %w\", err)\n\t\t}\n\n\t\treturn utils.NewToolResultText(string(r)), projectVisibilities(minimalProjects), nil, nil\n\t}\n\n\treturn nil, nil, nil, fmt.Errorf(\"unexpected state in listProjects\")\n}\n\n// listProjectsFromBothOwnerTypes fetches projects from both user and org endpoints\n// when owner_type is not specified, combining the results with owner_type labels.\nfunc listProjectsFromBothOwnerTypes(ctx context.Context, client *github.Client, owner string, opts *github.ListProjectsOptions) (*mcp.CallToolResult, []bool, any, error) {\n\tvar minimalProjects []MinimalProject\n\tvar resp *github.Response\n\n\t// Fetch user projects\n\tuserProjects, userResp, userErr := client.Projects.ListUserProjects(ctx, owner, opts)\n\tif userErr == nil && userResp.StatusCode == http.StatusOK {\n\t\tfor _, project := range userProjects {","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/projects.go#L1091-L1127","documentation":"Returned by listProjects when json.Marshal fails on the response map containing minimalProjects and pageInfo. The MinimalProject values are plain structs of strings, ints, pointers, and time.Time — all JSON-serializable — so in practice this error is near-unreachable; it exists to satisfy error handling. If it ever fires, a struct field of an unmarshalable type (chan, func, complex, or a marshal-time error from a custom MarshalJSON) is the cause.","triggerScenarios":"A MinimalProject field gaining a chan/func/complex type or a custom MarshalJSON that returns an error; unsupported NaN/Inf in a float field (json.Marshal rejects those); a cyclic pointer structure introduced by refactoring.","commonSituations":"Contributors extending MinimalProject with non-serializable fields during feature work; embedding time values that a custom marshaller chokes on for zero dates. End users essentially never see this from argument input.","solutions":["If you are a server contributor: check the failing struct for func/chan/complex fields or custom MarshalJSON methods and fix the type","As a tool caller: capture the full error (it wraps the json error with type details) and report it as a server-side bug; retrying with different arguments will not help","Pin/upgrade to a released server version where the regression is not present","If NaN/Inf may enter floats, sanitize them before they reach the response struct"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"result, vis, resp, err := listProjects(ctx, client, owner, opts)\nif err != nil {\n    if errors.Is(err, errJSONMarshalPrefix) || strings.Contains(err.Error(), \"failed to marshal response\") {\n        // internal serialization defect: do not retry; capture server version and report\n        reportServerBug(err)\n        return err\n    }\n    return err\n}","preventionTips":["Treat 'failed to marshal response' as a server bug, not an input problem — don't retry with mutated args","Keep a marshal smoke test (json.Marshal on sample response structs) in CI when contributing response types","Pin known-good server versions in deployment to isolate regressions"],"tags":["go","json","internal","unreachable-in-practice"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}