prestodb/presto · error · PageTransportErrorException

%s header is not set: %s

Error message

%s header is not set: %s

What it means

After a successful 200 response, the client validates the Content-Type header; if it is absent, a PageTransportErrorException is thrown. A 200 response without Content-Type is treated as a protocol violation from the task server.

Source

Thrown at presto-spark-base/src/main/java/com/facebook/presto/spark/execution/http/PrestoSparkHttpTaskClient.java:763

                                    body.append(line + "\n");
                                }
                            }
                        }
                    }
                    catch (RuntimeException | IOException e) {
                        // Ignored. Just return whatever message we were able to decode
                    }
                    throw new PageTransportErrorException(
                            HostAddress.fromUri(request.url().uri()),
                            format("Expected response code to be 200, but was %s:%n%s",
                                    response.code(),
                                    body.toString()));
                }

                // invalid content type can happen when an error page is returned, but is unlikely given the above 200
                String contentType = response.header(CONTENT_TYPE);
                if (contentType == null) {
                    throw new PageTransportErrorException(
                            HostAddress.fromUri(request.url().uri()),
                            format("%s header is not set: %s", CONTENT_TYPE, response));
                }
                if (!mediaTypeMatches(contentType, PRESTO_PAGES_TYPE)) {
                    throw new PageTransportErrorException(
                            HostAddress.fromUri(request.url().uri()),
                            format("Expected %s response from server but got %s", PRESTO_PAGES_TYPE, contentType));
                }

                String taskInstanceId = getTaskInstanceId(request, response);
                long token = getToken(request, response);
                long nextToken = getNextToken(request, response);
                boolean complete = getComplete(request, response);

                ResponseBody responseBody = response.body();
                if (responseBody == null) {
                    throw new PageTransportErrorException(
                            HostAddress.fromUri(request.url().uri()),

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect what actually answered on that host/port — the response printed in the message reveals if a proxy or wrong service replied
  2. Fix the proxy/load balancer to pass through the Content-Type header
  3. Verify the task server port/URI configuration points at the Presto Spark task server
  4. Retry the request; transient proxy misrouting can be intermittent

Example fix

// validate the endpoint before heavy use
// curl -i http://<host>:<port>/v2/task/... => must include Content-Type: application/x-presto-pages or similar
// fix proxy config to preserve headers:
// before (nginx): proxy_pass http://tasks;
// after (nginx): proxy_pass http://tasks; proxy_set_header Content-Type $upstream_http_content_type;
Defensive patterns

Strategy: try-catch

Validate before calling

// probe response headers from the task endpoint
Response probe = httpClient.newCall(new Request.Builder().url(taskUri).head().build()).execute();
if (probe.header("Content-Type") == null) throw new IllegalStateException("proxy stripping Content-Type");

Type guard

null

Try / catch

try {
    return taskClient.handle(request);
}
catch (PageTransportErrorException e) {
    if (e.getMessage() != null && e.getMessage().contains("header is not set")) {
        // inspect what service actually answered; check proxy config, then retry
    }
    throw e;
}

Prevention

When it happens

Trigger: handle() receives a 200 response whose header map contains no CONTENT_TYPE value — contentType == null triggers the throw with the full response in the message.

Common situations: Intermediary proxies/CDNs stripping the Content-Type header; a non-Presto service (e.g. a default web server page) answering on the task port; misconfigured reverse proxy rewriting responses.

Related errors


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