microsoft/aspire · error · InvalidOperationException

ADC request ' ' returned an empty response.

Error message

ADC request '{method} {path}' returned an empty response.

What it means

AzureDevComputeClient.SendAsync deserializes the ADC (Azure Dev Compute) HTTP response body into T. When EnsureSuccessAsync passes (no HTTP error) but the JSON body deserializes to null — typically an empty or literal-null body — the client treats this as an unexpected protocol state and throws.

Solutions

  1. Retry the request — an empty 200 can be transient
  2. Verify the request path and scope match the intended ADC resource
  3. Check ADC service health/status for incidents
  4. Capture the raw response body (logging/diagnostics) to confirm whether the body was empty or mismatched and report the issue if reproducible

Example fix

// hardening the call site
try
{
    var resource = await client.GetAsync(scope, method, path, ct);
    // use resource
}
catch (InvalidOperationException ex) when (ex.Message.Contains("returned an empty response"))
{
    logger.LogWarning(ex, "ADC returned an empty body for {Method} {Path}; retrying", method, path);
    // retry or fall back
}
Defensive patterns

Strategy: retry

Validate before calling

// pre-check: verify path/scope before calling the ADC client
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("ADC path required");

Try / catch

try { return await client.GetAsync(scope, method, path, ct); } catch (InvalidOperationException ex) when (ex.Message.Contains("returned an empty response")) { await Task.Delay(backoff, ct); return await client.GetAsync(scope, method, path, ct); }

Prevention

When it happens

Trigger: An ADC endpoint returns 200 with an empty body or 'null' body where a T payload is expected, during SendAsync calls such as GET/list operations against the Azure Dev Compute service.

Common situations: Transient service-side issues returning empty 200s; proxy/gateway stripping the body; hitting a wrong path whose success response has no body; service contract drift between client and API version.

Understand the failure class

Background: "empty response", "returned no data", "empty embeddings": what HTTP 200-with-empty-body errors mean across libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/5615e63a6469a080. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Azure.Sandboxes/Internal/Adc/AzureDevComputeClient.cs:217

    private async Task<T> SendAsync<T>(
        AzureDevComputeResourceScope scope,
        HttpMethod method,
        string path,
        object? content,
        CancellationToken cancellationToken,
        Func<T>? notFoundFactory = null)
    {
        using var response = await SendWithRetryAsync(scope, method, path, content, cancellationToken).ConfigureAwait(false);
        if (response.StatusCode == HttpStatusCode.NotFound && notFoundFactory is not null)
        {
            return notFoundFactory();
        }

        await EnsureSuccessAsync(response, method, path, cancellationToken).ConfigureAwait(false);

        var result = await response.Content.ReadFromJsonAsync<T>(s_jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
        return result ?? throw new InvalidOperationException($"ADC request '{method} {path}' returned an empty response.");
    }

    private async Task<T> SendCreateAsync<T>(
        AzureDevComputeResourceScope scope,
        HttpMethod method,
        string path,
        object content,
        CancellationToken cancellationToken)
    {
        HttpResponseMessage response;
        try
        {
            response = await SendWithRetryAsync(
                scope,
                method,
                path,
                content,
                cancellationToken,

View on GitHub (pinned to 25830f84bd)