{"record":{"id":"a090eb4fa7c5a2d4","repo":"github/github-mcp-server","slug":"failed-to-marshal-discussion-categories-w","errorCode":null,"errorMessage":"failed to marshal discussion categories: %w","messagePattern":"failed to marshal discussion categories: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/github/discussions.go","lineNumber":1098,"sourceCode":"\t\t\t\t\t\"name\": string(c.Name),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\t// Create response with pagination info\n\t\t\tresponse := map[string]any{\n\t\t\t\t\"categories\": categories,\n\t\t\t\t\"pageInfo\": map[string]any{\n\t\t\t\t\t\"hasNextPage\":     q.Repository.DiscussionCategories.PageInfo.HasNextPage,\n\t\t\t\t\t\"hasPreviousPage\": q.Repository.DiscussionCategories.PageInfo.HasPreviousPage,\n\t\t\t\t\t\"startCursor\":     string(q.Repository.DiscussionCategories.PageInfo.StartCursor),\n\t\t\t\t\t\"endCursor\":       string(q.Repository.DiscussionCategories.PageInfo.EndCursor),\n\t\t\t\t},\n\t\t\t\t\"totalCount\": q.Repository.DiscussionCategories.TotalCount,\n\t\t\t}\n\n\t\t\tout, err := json.Marshal(response)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to marshal discussion categories: %w\", err)\n\t\t\t}\n\t\t\tresult := utils.NewToolResultText(string(out))\n\t\t\t// Discussion categories are repo-defined structural metadata\n\t\t\t// (trusted); confidentiality follows repo visibility.\n\t\t\tresult = attachRepoVisibilityIFCLabelLazy(ctx, deps, owner, repo, result, ifc.LabelRepoMetadata)\n\t\t\treturn result, nil, nil\n\t\t},\n\t)\n}\n","sourceCodeStart":1080,"sourceCodeEnd":1108,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/discussions.go#L1080-L1108","documentation":"list_discussion_categories marshals a response map of the categories slice, pageInfo (bools and cursor strings), and totalCount int after a successful GraphQL query. All values are primitives derived from GraphQL scalars, so json.Marshal's failure modes (unsupported types, cycles, NaN) are not reachable; the branch guards against future type regressions in the response construction.","triggerScenarios":"A refactor moving raw githubv4 category objects into the categories slice without projecting to plain maps; addition of float fields that could be NaN; cyclic structures from embedding. Current GitHub category data (ids, names, cursors) cannot trip it.","commonSituations":"Forks adding category description/emoji fields as typed objects; library upgrades changing embedded struct shapes; test doubles with unmarshalable fields.","solutions":["Project categories into maps of string/int before insertion into the response","Add a golden-file test for the categories response JSON","On occurrence, inspect element types of the categories slice — the defect is in this handler's projection, not the API call","Do not retry the tool: the query already succeeded and marshal outcome is deterministic per input"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := json.Marshal(response)\nif err != nil {\n\treturn nil, nil, fmt.Errorf(\"failed to marshal discussion categories: %w\", err)\n}","preventionTips":["Project category objects into plain maps (id, name strings)","Golden-test the categories response JSON","Do not retry on marshal errors — the query already succeeded and the outcome is deterministic"],"tags":["go","json-marshal","defensive-code","discussions"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}