{"record":{"id":"c9aa16067693280c","repo":"getsops/sops","slug":"github-api-request-failed-v","errorCode":null,"errorMessage":"GitHub API request failed: %v","messagePattern":"GitHub API request failed: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"version/version.go","lineNumber":218,"sourceCode":"// LatestReleaseUsingAPI retrieves the most recent release version from the\n// GitHub API. It returns the latest version as a string, along with its\n// corresponding URL, or an error in case of request failure or parsing issues\n// with the response.\n//\n// This approach boasts higher reliability compared to\n// LatestReleaseUsingRedirect as it leverages the versioned GitHub API.\n// However, it can be affected by GitHub API rate limiting.\nfunc (f releaseFetcher) LatestReleaseUsingAPI(repository string) (tag, url string, err error) {\n\treq, err := http.NewRequest(http.MethodGet, fmt.Sprintf(\"%s/%s/releases/latest\", f.apiEndpoint, repository), nil)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\treq.Header.Set(\"Accept\", \"application/vnd.github+json\")\n\treq.Header.Set(\"X-GitHub-Api-Version\", \"2022-11-28\")\n\n\tres, err := cleanhttp.DefaultClient().Do(req)\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"GitHub API request failed: %v\", err)\n\t}\n\tif res.Body != nil {\n\t\tdefer res.Body.Close()\n\t}\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn \"\", \"\", fmt.Errorf(\"GitHub API request failed with status code: %d\", res.StatusCode)\n\t}\n\n\ttype release struct {\n\t\tURL string `json:\"html_url\"`\n\t\tTag string `json:\"tag_name\"`\n\t}\n\tvar m release\n\tif err := json.NewDecoder(res.Body).Decode(&m); err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\treturn m.Tag, m.URL, nil","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/version/version.go#L200-L236","documentation":"Error \"GitHub API request failed: %v\" thrown in getsops/sops.","triggerScenarios":"Thrown at version/version.go:218 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}