{"record":{"id":"843d10de0cbf7a8e","repo":"Devolutions/UniGetUI","slug":"github-returned-an-empty-response","errorCode":null,"errorMessage":"GitHub returned an empty response.","messagePattern":"GitHub returned an empty response\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/UniGetUI.Interface.IpcApi/GitHubApiClient.cs","lineNumber":239,"sourceCode":"    }\n\n    private async Task<T> SendAsync<T>(\n        HttpRequestMessage message,\n        JsonTypeInfo<T> typeInfo,\n        CancellationToken cancellationToken\n    )\n    {\n        using HttpResponseMessage response = await _httpClient.SendAsync(message, cancellationToken);\n        string content = await response.Content.ReadAsStringAsync(cancellationToken);\n        if (!response.IsSuccessStatusCode)\n        {\n            throw new HttpRequestException(\n                $\"GitHub request failed with HTTP {(int)response.StatusCode} ({response.ReasonPhrase}): {GetErrorMessage(content)}\"\n            );\n        }\n\n        return JsonSerializer.Deserialize(content, typeInfo)\n            ?? throw new InvalidOperationException(\"GitHub returned an empty response.\");\n    }\n\n    private static StringContent CreateJsonContent<T>(T value, JsonTypeInfo<T> typeInfo)\n    {\n        return new StringContent(\n            JsonSerializer.Serialize(value, typeInfo),\n            System.Text.Encoding.UTF8,\n            \"application/json\"\n        );\n    }\n\n    private static string GetErrorMessage(string content)\n    {\n        if (string.IsNullOrWhiteSpace(content))\n            return \"No response body.\";\n\n        try\n        {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/Devolutions/UniGetUI/blob/9b1d7d0eab91620fc15c86b36676532095936ae3/src/UniGetUI.Interface.IpcApi/GitHubApiClient.cs#L221-L257","documentation":"In GitHubApiClient.SendAsync, after a 2xx response the body is deserialized via JsonSerializer.Deserialize with the source-generated JsonTypeInfo. If the result is null (the body parsed to a JSON null or the deserializer produced a null reference for the target type), an InvalidOperationException is thrown. This is a defensive guard against GitHub returning an empty or null-valued body for an endpoint that is contractually expected to return a populated object.","triggerScenarios":"GitHub returns HTTP 200 with a body of \"null\" or an empty string for an endpoint expected to yield a non-null object (e.g. user, gist, or token). This is rare but can happen if an internal GitHub proxy strips the body, a CDN serves a cached null response, or the requested resource is in a transient state that serializes to null.","commonSituations":"A transient GitHub API anomaly returns 200 with an empty body. A custom proxy or gateway between the client and GitHub drops the response body. The gist or user endpoint returns a representation that the source-generated deserializer maps to null (e.g. an unexpected schema where all properties are absent and the type has no required members).","solutions":["Retry the GitHub API call — an empty 200 is typically transient.","Verify no intermediary proxy is stripping response bodies.","Check GitHub's status page for ongoing API anomalies.","Log the raw response content for the failing endpoint to diagnose whether the body is empty, null, or schema-mismatched."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var result = await client.GetGistAsync(id); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"empty response\"))\n{ /* transient; retry once or fall back */ }","preventionTips":["Retry once on an 'empty response' error as it is typically transient.","Log the raw response content when this occurs to diagnose schema/proxy issues.","Ensure no intermediary strips response bodies."],"tags":["github","http","json","api","ipc"],"backgroundTag":null,"analyzedSha":"9b1d7d0eab91620fc15c86b36676532095936ae3","analyzedAt":"2026-08-13T12:19:18.278Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}