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

  1. Retry the GitHub API call — an empty 200 is typically transient.
  2. Verify no intermediary proxy is stripping response bodies.
  3. Check GitHub's status page for ongoing API anomalies.
  4. 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

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


AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13). Data as JSON: /api/errors/843d10de0cbf7a8e. Report an issue: GitHub.