{"record":{"id":"106d879f4b46ef8a","repo":"github/github-mcp-server","slug":"failed-to-marshal-advisory-w","errorCode":null,"errorMessage":"failed to marshal advisory: %w","messagePattern":"failed to marshal advisory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/github/security_advisories.go","lineNumber":380,"sourceCode":"\t\t\t}\n\n\t\t\tadvisory, resp, err := client.SecurityAdvisories.GetGlobalSecurityAdvisories(ctx, ghsaID)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to get advisory: %w\", err)\n\t\t\t}\n\t\t\tdefer func() { _ = resp.Body.Close() }()\n\n\t\t\tif resp.StatusCode != http.StatusOK {\n\t\t\t\tbody, err := io.ReadAll(resp.Body)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to read response body: %w\", err)\n\t\t\t\t}\n\t\t\t\treturn ghErrors.NewGitHubAPIStatusErrorResponse(ctx, \"failed to get advisory\", resp, body), nil, nil\n\t\t\t}\n\n\t\t\tr, err := json.Marshal(advisory)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to marshal advisory: %w\", err)\n\t\t\t}\n\n\t\t\tresult := utils.NewToolResultText(string(r))\n\t\t\t// A global advisory is world-readable (public) but externally\n\t\t\t// authored (untrusted).\n\t\t\tresult = attachStaticIFCLabel(ctx, deps, result, ifc.LabelGlobalSecurityAdvisory())\n\t\t\treturn result, nil, nil\n\t\t},\n\t)\n}\n\nfunc ListOrgRepositorySecurityAdvisories(t translations.TranslationHelperFunc) inventory.ServerTool {\n\treturn NewTool(\n\t\tToolsetMetadataSecurityAdvisories,\n\t\tmcp.Tool{\n\t\t\tName:        \"list_org_repository_security_advisories\",\n\t\t\tDescription: t(\"TOOL_LIST_ORG_REPOSITORY_SECURITY_ADVISORIES_DESCRIPTION\", \"List repository security advisories for a GitHub organization.\"),\n\t\t\tAnnotations: &mcp.ToolAnnotations{","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/security_advisories.go#L362-L398","documentation":"json.Marshal of the *github.GlobalAdvisory value returned by the API failed. Marshaling plain data structs essentially never fails; an error means the value contains an unsupported type (chan/func), a cycle, NaN/Inf floats, or a custom MarshalJSON that returned an error.","triggerScenarios":"Upstream go-github type changes introducing unsupported fields or a failing MarshalJSON; advisory payloads containing values the local Go version cannot encode.","commonSituations":"Version skew after upgrading go-github without regenerating/aligning types; locally patched structs.","solutions":["Log the underlying error - it names the offending type or field","Align the go-github dependency version with the one this server build expects","Add a unit test that unmarshals a sample advisory JSON and re-marshals it to catch regressions"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"r, err := json.Marshal(advisory)\nif err != nil {\n\t// log the offending payload shape and degrade rather than fail the whole tool call\n\tslog.Error(\"marshal advisory failed\", \"error\", err)\n\tr, err = json.Marshal(struct{ Error string }{\"advisory could not be serialized\"})\n}","preventionTips":["Pin dependency versions (go-github) in go.mod to avoid type drift","Add round-trip marshal unit tests for every API type you serialize","Treat marshal failures of plain API structs as bugs to fix, not runtime conditions to handle"],"tags":["json","serialization","security-advisory"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}