{"record":{"id":"c66a400344320958","repo":"prestodb/presto","slug":"expected-s-header-c66a40","errorCode":null,"errorMessage":"Expected %s header","messagePattern":"Expected (.+?) header","errorType":"exception","errorClass":"PageTransportErrorException","httpStatus":null,"severity":"error","filePath":"presto-spark-base/src/main/java/com/facebook/presto/spark/execution/http/PrestoSparkHttpTaskClient.java","lineNumber":813,"sourceCode":"            }\n        }\n\n        private static ListMultimap<OkHttpHeaderName, String> convertHeaders(Response response)\n        {\n            ImmutableListMultimap.Builder<OkHttpHeaderName, String> builder = ImmutableListMultimap.builder();\n            for (String name : response.headers().names()) {\n                for (String value : response.headers().values(name)) {\n                    builder.put(OkHttpHeaderName.of(name), value);\n                }\n            }\n            return builder.build();\n        }\n\n        private static String getTaskInstanceId(Request request, Response response)\n        {\n            String taskInstanceId = response.header(PRESTO_TASK_INSTANCE_ID);\n            if (taskInstanceId == null) {\n                throw new PageTransportErrorException(HostAddress.fromUri(request.url().uri()), format(\"Expected %s header\", PRESTO_TASK_INSTANCE_ID));\n            }\n            return taskInstanceId;\n        }\n\n        private static long getToken(Request request, Response response)\n        {\n            String tokenHeader = response.header(PRESTO_PAGE_TOKEN);\n            if (tokenHeader == null) {\n                throw new PageTransportErrorException(HostAddress.fromUri(request.url().uri()), format(\"Expected %s header\", PRESTO_PAGE_TOKEN));\n            }\n            return Long.parseLong(tokenHeader);\n        }\n\n        private static long getNextToken(Request request, Response response)\n        {\n            String nextTokenHeader = response.header(PRESTO_PAGE_NEXT_TOKEN);\n            if (nextTokenHeader == null) {\n                throw new PageTransportErrorException(HostAddress.fromUri(request.url().uri()), format(\"Expected %s header\", PRESTO_PAGE_NEXT_TOKEN));","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-base/src/main/java/com/facebook/presto/spark/execution/http/PrestoSparkHttpTaskClient.java#L795-L831","documentation":"Every pages response must carry the X-Presto-Task-Instance-Id header so the client can pin subsequent requests to the same worker task instance. When the header is missing the client cannot verify response identity, so it throws PageTransportErrorException with 'Expected X-Presto-Task-Instance-Id header'.","triggerScenarios":"The server responds with correct content type but omits the PRESTO_TASK_INSTANCE_ID header — typically a non-worker component answered the request, or a worker built/patched without the header-writing code.","commonSituations":"Intermediary stripping custom X-Presto-* headers; wrong service listening on the worker port (e.g. an HTTP health endpoint); mixed Presto versions where the response protocol differs; request hitting a stale decommissioned endpoint.","solutions":["Log the full response headers of the failing request to confirm what the server sent.","Verify the request reached a genuine Presto native worker on the correct port.","Check whether a proxy or service mesh strips unrecognized X-Presto-* headers and exempt them.","Align Presto client and worker versions so the response contract matches.","Retry after a worker replacement — a half-dead worker can answer without the full header set."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate required headers before trusting the response\nString taskId = response.header(\"X-Presto-Task-Instance-Id\");\nif (taskId == null) throw new IOException(\"Response missing task-instance-id from \" + request.url());","typeGuard":"boolean hasTaskInstanceId(Response r) {\n    return r.header(\"X-Presto-Task-Instance-Id\") != null;\n}","tryCatchPattern":"try {\n    client.getPagesRequest(...);\n} catch (PageTransportErrorException e) {\n    if (e.getMessage().contains(\"X-Presto-Task-Instance-Id\")) {\n        // endpoint is not a worker or headers are stripped: re-route/retry\n    }\n    throw e;\n}","preventionTips":["Bypass proxies that strip custom X-Presto-* headers.","Verify target host:port maps to a real native worker.","Keep client/worker protocol versions aligned.","Use retry-after-worker-replacement logic for stale endpoints."],"tags":["http","headers","spark","task-instance"],"backgroundTag":"missing-response-header","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}