{"record":{"id":"88f05ec858653dda","repo":"github/github-mcp-server","slug":"failed-to-marshal-response-w-88f05e","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/pullrequests.go","lineNumber":312,"sourceCode":"\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx,\n\t\t\t\"failed to get combined status\",\n\t\t\tresp,\n\t\t\terr,\n\t\t), nil\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tbody, err := io.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to read response body: %w\", err)\n\t\t}\n\t\treturn ghErrors.NewGitHubAPIStatusErrorResponse(ctx, \"failed to get combined status\", resp, body), nil\n\t}\n\n\tr, err := json.Marshal(convertToMinimalCombinedStatus(status))\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\nfunc GetPullRequestCheckRuns(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) {\n\t// First get the PR to get the head SHA\n\tpr, resp, err := client.PullRequests.Get(ctx, owner, repo, pullNumber)\n\tif err != nil {\n\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx,\n\t\t\t\"failed to get pull request\",\n\t\t\tresp,\n\t\t\terr,\n\t\t), nil\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/pullrequests.go#L294-L330","documentation":"get_pull_request_status marshals convertToMinimalCombinedStatus(status) with json.Marshal before returning the tool result. Go's json.Marshal only errors on unsupported types (func, chan, complex), cycles, or NaN/Inf floats — none of which this plain data struct contains. This branch is defensive dead code; if it ever fires it signals a regression in the MinimalCombinedStatus type, not a runtime condition.","triggerScenarios":"Someone adds a func-typed, chan-typed, or self-referencing field to MinimalCombinedStatus or its nested types (MinimalStatus/MinimalStatusContext); production data flows through and Marshal returns *json.UnsupportedTypeError or *json.UnsupportedValueError.","commonSituations":"Refactors of the minimal-types file that add computed getters or callbacks; almost never seen from API data alone because GitHub JSON decodes into plain strings/ints/bools.","solutions":["Diff the MinimalCombinedStatus struct family — look for newly added func, chan, or pointer-cycle fields","Add a unit test that round-trips a realistic CombinedStatus through convertToMinimalCombinedStatus + json.Marshal","Keep minimal types to plain strings/ints/bools; put derived values in precomputed string fields"],"exampleFix":"// before\ntype MinimalCombinedStatus struct {\n\tState    string             `json:\"state\"`\n\tStatuses []MinimalStatus    `json:\"statuses\"`\n\tFilter   func(string) bool  `json:\"-\"` // json.Marshal never sees func fields with json:\"-\"... but without the tag it fails\n}\n\n// after — keep the type JSON-safe\ntype MinimalCombinedStatus struct {\n\tState    string          `json:\"state\"`\n\tStatuses []MinimalStatus `json:\"statuses\"`\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"func isMarshalTypeErr(err error) bool {\n\tvar typeErr *json.UnsupportedTypeError\n\tvar valErr *json.UnsupportedValueError\n\treturn errors.As(err, &typeErr) || errors.As(err, &valErr)\n}","tryCatchPattern":"r, err := json.Marshal(minimalStatus)\nif err != nil {\n\t// not retryable: log a bug-level alert and return a tool error\ndeps.Logger(ctx).Error(\"marshal regression\", \"err\", err)\n\treturn nil, fmt.Errorf(\"internal serialization failure: %w\", err)\n}","preventionTips":["Unit-test json round-trips of all Minimal* types in CI","Never add func/chan fields or cyclic pointers to response structs","Treat this error as a build/regression signal, not an operational incident"],"tags":["go","json","mcp","serialization","defensive-code"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}