{"record":{"id":"062b3f2613e3d84d","repo":"github/github-mcp-server","slug":"failed-to-list-repository-security-advisories-w","errorCode":null,"errorMessage":"failed to list repository security advisories: %w","messagePattern":"failed to list repository security advisories: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/security_advisories.go","lineNumber":299,"sourceCode":"\t\t\tclient, err := deps.GetClient(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to get GitHub client: %w\", err)\n\t\t\t}\n\n\t\t\topts := &github.ListRepositorySecurityAdvisoriesOptions{}\n\t\t\tif direction != \"\" {\n\t\t\t\topts.Direction = direction\n\t\t\t}\n\t\t\tif sortField != \"\" {\n\t\t\t\topts.Sort = sortField\n\t\t\t}\n\t\t\tif state != \"\" {\n\t\t\t\topts.State = state\n\t\t\t}\n\n\t\t\tadvisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, owner, repo, opts)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to list repository security advisories: %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 list repository advisories\", resp, body), nil, nil\n\t\t\t}\n\n\t\t\tr, err := json.Marshal(advisories)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fmt.Errorf(\"failed to marshal advisories: %w\", err)\n\t\t\t}\n\n\t\t\tresult := utils.NewToolResultText(string(r))\n\t\t\t// Repository advisories carry externally authored prose (untrusted).","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/security_advisories.go#L281-L317","documentation":"client.SecurityAdvisories.ListRepositorySecurityAdvisories returned an error. go-github converts any non-2xx into an error, so the usual causes are 404 (owner/repo typo, repo renamed or deleted, or token lacks read access to a private repo), 403 (rate limit or blocked), and transport failures. Like the global variant, the raw error is wrapped directly rather than going through the structured GitHubAPIErrorResponse helper.","triggerScenarios":"Calling the tool with a misspelled owner/repo; repo renamed so the old name 404s; PAT without access to the private repo; primary rate limit exhausted; DNS/TLS failures to the API host.","commonSituations":"Hardcoded repo names drifting after renames; scoped fine-grained PATs missing the repository; CI rate-limit pressure.","solutions":["Unwrap with errors.As(err, *github.ErrorResponse): 404 -> verify owner/repo spelling and that the token can see the repo; 403 -> check rate limit and scopes","Confirm the repo is reachable: curl -H \"Authorization: Bearer $TOKEN\" https://api.github.com/repos/OWNER/REPO","On rate limits, back off until x-ratelimit-reset","Code improvement: use NewGitHubAPIErrorResponse for structured API-error messages"],"exampleFix":"// before\nadvisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, owner, repo, opts)\nif err != nil {\n    return nil, nil, fmt.Errorf(\"failed to list repository security advisories: %w\", err)\n}\n// after\nvar ghErr *github.ErrorResponse\nif errors.As(err, &ghErr) {\n    return ghErrors.NewGitHubAPIErrorResponse(ctx, \"failed to list repository security advisories\", resp, err), nil, nil\n}\nreturn nil, nil, fmt.Errorf(\"failed to list repository security advisories: %w\", err)","handlingStrategy":"retry","validationCode":"// Verify the repo is visible with this token before listing advisories\nrepoResp, err := client.Repositories.Get(ctx, owner, repo)\nif err != nil {\n    var ghErr *github.ErrorResponse\n    if errors.As(err, &ghErr) && ghErr.Response != nil && ghErr.Response.StatusCode == 404 {\n        return fmt.Errorf(\"repo %s/%s not visible to this token\", owner, repo)\n    }\n    return fmt.Errorf(\"repo check failed: %w\", err)\n}","typeGuard":"func isGitHubAPIError(err error) (*github.ErrorResponse, bool) {\n\tvar ghErr *github.ErrorResponse\n\tif errors.As(err, &ghErr) {\n\t\treturn ghErr, true\n\t}\n\treturn nil, false\n}\n\nfunc isRetryableListErr(err error) bool {\n\tghErr, ok := isGitHubAPIError(err)\n\tif !ok {\n\t\tvar netErr net.Error\n\t\treturn errors.As(err, &netErr)\n\t}\n\treturn ghErr.Response != nil &&\n\t\t(ghErr.Response.StatusCode == 429 || ghErr.Response.StatusCode >= 500)\n}","tryCatchPattern":"advisories, resp, err := client.SecurityAdvisories.ListRepositorySecurityAdvisories(ctx, owner, repo, opts)\nif err != nil {\n    if ghErr, ok := isGitHubAPIError(err); ok {\n        switch ghErr.Response.StatusCode {\n        case 404:\n            return nil, fmt.Errorf(\"repo %s/%s not found or inaccessible; check spelling and token scope\", owner, repo)\n        case 403, 429:\n            time.Sleep(backoff)\n            return listAgain(ctx, owner, repo, opts)\n        }\n    }\n    if isRetryableListErr(err) {\n        return listAgain(ctx, owner, repo, opts)\n    }\n    return nil, fmt.Errorf(\"failed to list repository security advisories: %w\", err)\n}","preventionTips":["Verify owner/repo spelling and token visibility before listing advisories","For private repos, confirm the PAT has read access to that repository","Only retry on 429/5xx and transport errors; 404/403 need argument or scope fixes"],"tags":["go","mcp","github-api","not-found","rate-limit","security-advisory"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}