Devolutions/UniGetUI · error · InvalidOperationException
GitHub returned an empty response.
Error message
GitHub returned an empty response.
What it means
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.
Source
Thrown at src/UniGetUI.Interface.IpcApi/GitHubApiClient.cs:239
}
private async Task<T> SendAsync<T>(
HttpRequestMessage message,
JsonTypeInfo<T> typeInfo,
CancellationToken cancellationToken
)
{
using HttpResponseMessage response = await _httpClient.SendAsync(message, cancellationToken);
string content = await response.Content.ReadAsStringAsync(cancellationToken);
if (!response.IsSuccessStatusCode)
{
throw new HttpRequestException(
$"GitHub request failed with HTTP {(int)response.StatusCode} ({response.ReasonPhrase}): {GetErrorMessage(content)}"
);
}
return JsonSerializer.Deserialize(content, typeInfo)
?? throw new InvalidOperationException("GitHub returned an empty response.");
}
private static StringContent CreateJsonContent<T>(T value, JsonTypeInfo<T> typeInfo)
{
return new StringContent(
JsonSerializer.Serialize(value, typeInfo),
System.Text.Encoding.UTF8,
"application/json"
);
}
private static string GetErrorMessage(string content)
{
if (string.IsNullOrWhiteSpace(content))
return "No response body.";
try
{View on GitHub (pinned to 9b1d7d0eab)
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.
Defensive patterns
Strategy: retry
Try / catch
try { var result = await client.GetGistAsync(id); }
catch (InvalidOperationException ex) when (ex.Message.Contains("empty response"))
{ /* transient; retry once or fall back */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- GitHub request failed with HTTP {(int)response.StatusCode} (
- The GitHub backup gist could not be created.
- The pending GitHub device flow has expired. Start sign-in ag
- GitHub did not return an access token.
- GitHub sign-in did not complete successfully. Finish the dev
AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13).
Data as JSON: /api/errors/843d10de0cbf7a8e.
Report an issue: GitHub.