prestodb/presto · error · ProxyException

No Content-Type set in response from remote Presto server

Error message

No Content-Type set in response from remote Presto server

What it means

A 200 response from the remote Presto server must carry a Content-Type header so the proxy can validate it is JSON. When the header is absent, the proxy throws this ProxyException. It indicates a malformed or non-conformant upstream response.

Source

Thrown at presto-proxy/src/main/java/com/facebook/presto/proxy/ProxyResponseHandler.java:58

    public ProxyResponse handleException(Request request, Exception exception)
    {
        throw new ProxyException("Request to remote Presto server failed", exception);
    }

    @Override
    public ProxyResponse handle(Request request, Response response)
    {
        if (response.getStatusCode() == NO_CONTENT.code()) {
            return new ProxyResponse(response.getHeaders(), new byte[0]);
        }

        if (response.getStatusCode() != OK.code()) {
            throw new ProxyException(format("Bad status code from remote Presto server: %s: %s", response.getStatusCode(), readBody(response)));
        }

        String contentType = response.getHeader(CONTENT_TYPE);
        if (contentType == null) {
            throw new ProxyException("No Content-Type set in response from remote Presto server");
        }
        if (!MediaType.parse(contentType).is(MEDIA_TYPE_JSON)) {
            throw new ProxyException("Bad Content-Type from remote Presto server:" + contentType);
        }

        try {
            return new ProxyResponse(response.getHeaders(), toByteArray(response.getInputStream()));
        }
        catch (IOException e) {
            throw new ProxyException("Failed reading response from remote Presto server", e);
        }
    }

    private static String readBody(Response response)
    {
        try {
            return new String(toByteArray(response.getInputStream()), US_ASCII);
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the actual raw response from the remote server (curl -v) to confirm the missing header.
  2. Check for intermediaries stripping Content-Type and fix their configuration.
  3. Ensure you are hitting the real Presto API endpoint, not a redirect or health page.
  4. Upgrade/fix the backend component producing headerless responses.
Defensive patterns

Strategy: validation

Validate before calling

// probe the endpoint and require a JSON content type
const probe = await fetch(backendUri + path, { headers });
const ct = probe.headers.get("content-type");
if (!ct || !ct.includes("application/json")) throw new Error("Missing/unexpected Content-Type: " + ct);

Prevention

When it happens

Trigger: The remote server responded 200 OK but omitted the Content-Type header entirely on a proxied response.

Common situations: Custom or misconfigured intermediary (load balancer, CDN) stripping headers; non-standard endpoint behind the remote server (e.g., a health/redirect handler); buggy custom Presto plugin or connector endpoint.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/20fb9c24bc0964a7. Report an issue: GitHub.