{"record":{"id":"5615e63a6469a080","repo":"microsoft/aspire","slug":"adc-request-method-path-returned-an-empty-response","errorCode":null,"errorMessage":"ADC request '{method} {path}' returned an empty response.","messagePattern":"ADC request '(.+?) (.+?)' returned an empty response\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/Internal/Adc/AzureDevComputeClient.cs","lineNumber":217,"sourceCode":"\n    private async Task<T> SendAsync<T>(\n        AzureDevComputeResourceScope scope,\n        HttpMethod method,\n        string path,\n        object? content,\n        CancellationToken cancellationToken,\n        Func<T>? notFoundFactory = null)\n    {\n        using var response = await SendWithRetryAsync(scope, method, path, content, cancellationToken).ConfigureAwait(false);\n        if (response.StatusCode == HttpStatusCode.NotFound && notFoundFactory is not null)\n        {\n            return notFoundFactory();\n        }\n\n        await EnsureSuccessAsync(response, method, path, cancellationToken).ConfigureAwait(false);\n\n        var result = await response.Content.ReadFromJsonAsync<T>(s_jsonSerializerOptions, cancellationToken).ConfigureAwait(false);\n        return result ?? throw new InvalidOperationException($\"ADC request '{method} {path}' returned an empty response.\");\n    }\n\n    private async Task<T> SendCreateAsync<T>(\n        AzureDevComputeResourceScope scope,\n        HttpMethod method,\n        string path,\n        object content,\n        CancellationToken cancellationToken)\n    {\n        HttpResponseMessage response;\n        try\n        {\n            response = await SendWithRetryAsync(\n                scope,\n                method,\n                path,\n                content,\n                cancellationToken,","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/Internal/Adc/AzureDevComputeClient.cs#L199-L235","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the request — an empty 200 can be transient","Verify the request path and scope match the intended ADC resource","Check ADC service health/status for incidents","Capture the raw response body (logging/diagnostics) to confirm whether the body was empty or mismatched and report the issue if reproducible"],"exampleFix":"// hardening the call site\ntry\n{\n    var resource = await client.GetAsync(scope, method, path, ct);\n    // use resource\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"returned an empty response\"))\n{\n    logger.LogWarning(ex, \"ADC returned an empty body for {Method} {Path}; retrying\", method, path);\n    // retry or fall back\n}","handlingStrategy":"retry","validationCode":"// pre-check: verify path/scope before calling the ADC client\nif (string.IsNullOrWhiteSpace(path)) throw new ArgumentException(\"ADC path required\");","typeGuard":null,"tryCatchPattern":"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); }","preventionTips":["Wrap ADC calls in a retry policy (e.g. Polly) for transient empty responses","Log raw response bodies when diagnosing empty-response failures","Pin ADC service/API versions to avoid contract drift","Monitor Azure service health for the ADC endpoint"],"tags":["http","azure","api","empty-response","network"],"backgroundTag":"empty-api-response","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}