{"record":{"id":"7bf1c41e12e4d454","repo":"github/github-mcp-server","slug":"failed-to-marshal-alerts-w","errorCode":null,"errorMessage":"failed to marshal alerts: %w","messagePattern":"failed to marshal alerts: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/github/secret_scanning.go","lineNumber":205,"sourceCode":"\t\t\t\treturn ghErrors.NewGitHubAPIErrorResponse(ctx,\n\t\t\t\t\tfmt.Sprintf(\"failed to list alerts for repository '%s/%s'\", owner, repo),\n\t\t\t\t\tresp,\n\t\t\t\t\terr,\n\t\t\t\t), nil, nil\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 list alerts\", resp, body), nil, nil\n\t\t\t}\n\n\t\t\tr, err := json.Marshal(alerts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to marshal alerts: %w\", err)\n\t\t\t}\n\n\t\t\tresult := utils.NewToolResultText(string(r))\n\t\t\t// Secret scanning alerts are access-restricted regardless of repo\n\t\t\t// visibility and surface the matched secret material itself, so the\n\t\t\t// label is always private-untrusted.\n\t\t\tresult = attachStaticIFCLabel(ctx, deps, result, ifc.LabelSecurityAlert())\n\t\t\treturn result, nil, nil\n\t\t},\n\t)\n}\n","sourceCodeStart":187,"sourceCodeEnd":217,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/secret_scanning.go#L187-L217","documentation":"Returned if json.Marshal fails on the []*github.SecretScanningAlert slice. Slices of plain data structs marshal without error, so this branch is defensive dead code, same as the single-alert marshal error. An actual occurrence would point to an incompatible go-github type change, not usage.","triggerScenarios":"No realistic API call produces this; the payload is a slice of JSON-safe structs.","commonSituations":"Not observed in practice.","solutions":["No runtime action needed - report upstream if it ever fires, including the go-github version"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to marshal alerts\") {\n    // not reachable with JSON-safe go-github structs: treat as upstream bug\n    log.Error(\"impossible marshal failure on SecretScanningAlert list\", \"err\", err)\n}","preventionTips":["No prevention needed - occurrence indicates an upstream type change","Pin the go-github module version to avoid silent struct drift"],"tags":["go","json","secret-scanning","dead-code"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}