{"record":{"id":"7e1ccab1f1fb4e53","repo":"CoplayDev/unity-mcp","slug":"github-request-failed-int-response-statuscode","errorCode":null,"errorMessage":"GitHub request failed: {(int)response.StatusCode} {response.ReasonPhrase} ({url})\\n{body}","messagePattern":"GitHub request failed: (.+?) (.+?) \\((.+?)\\)\\\\n(.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Setup/SkillSyncService.cs","lineNumber":297,"sourceCode":"\n        internal static HttpClient CreateGitHubClient()\n        {\n            var client = new HttpClient\n            {\n                Timeout = TimeSpan.FromSeconds(60)\n            };\n            client.DefaultRequestHeaders.UserAgent.ParseAdd(\"UnityMcpSkillSync/1.0\");\n            client.DefaultRequestHeaders.Accept.ParseAdd(\"application/vnd.github+json\");\n            return client;\n        }\n\n        internal static string DownloadString(HttpClient client, string url)\n        {\n            using var response = client.GetAsync(url).GetAwaiter().GetResult();\n            var body = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();\n            if (!response.IsSuccessStatusCode)\n            {\n                throw new InvalidOperationException($\"GitHub request failed: {(int)response.StatusCode} {response.ReasonPhrase} ({url})\\n{body}\");\n            }\n\n            return body;\n        }\n\n        private static byte[] DownloadBytes(HttpClient client, string url)\n        {\n            using var response = client.GetAsync(url).GetAwaiter().GetResult();\n            if (!response.IsSuccessStatusCode)\n            {\n                var body = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();\n                throw new InvalidOperationException($\"File download failed: {(int)response.StatusCode} {response.ReasonPhrase} ({url})\\n{body}\");\n            }\n\n            return response.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();\n        }\n\n        internal static string NormalizeRemotePath(string path)","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Setup/SkillSyncService.cs#L279-L315","documentation":"DownloadString throws when any GitHub REST API call (branches or git/trees) returns a non-success status. The message embeds the numeric status code, reason phrase, the requested URL, and the response body for diagnosis.","triggerScenarios":"403 Forbidden from unauthenticated rate limiting (~60 req/hr per IP); 404 Not Found for a wrong owner/repo/branch/tree; 401 if a private repo is targeted; 5xx during a GitHub outage.","commonSituations":"Repeated syncs exhausting the unauthenticated rate limit; typo in owner/repo; targeting a private repo (the service sends no auth token); GitHub incident.","solutions":["Read the status code in the message: 403 => rate limit, 404 => wrong identifier, 401 => private repo.","For 403: wait for the rate-limit reset window (check X-RateLimit headers) before retrying.","For 404: verify owner, repo, and branch spellings.","For private repos: the service has no token support, so sync from a public mirror/fork."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var json = SkillSyncService.DownloadString(client, url);\n}\ncatch (InvalidOperationException ex)\n{\n    if (ex.Message.Contains(\"403\"))\n        log?.Invoke(\"GitHub rate limit hit. Wait for the reset window before retrying.\");\n    else if (ex.Message.Contains(\"404\"))\n        log?.Invoke(\"GitHub returned 404. Check owner/repo/branch spelling.\");\n    throw;\n}","preventionTips":["Throttle sync frequency to stay under the unauthenticated rate limit.","Verify owner/repo/branch spellings before syncing.","Use a public repo or mirror; the service sends no auth token for private repos."],"tags":["github","api","http","rate-limit"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}