{"record":{"id":"20fb9c24bc0964a7","repo":"prestodb/presto","slug":"no-content-type-set-in-response-from-remote-presto","errorCode":null,"errorMessage":"No Content-Type set in response from remote Presto server","messagePattern":"No Content-Type set in response from remote Presto server","errorType":"exception","errorClass":"ProxyException","httpStatus":502,"severity":"error","filePath":"presto-proxy/src/main/java/com/facebook/presto/proxy/ProxyResponseHandler.java","lineNumber":58,"sourceCode":"    public ProxyResponse handleException(Request request, Exception exception)\n    {\n        throw new ProxyException(\"Request to remote Presto server failed\", exception);\n    }\n\n    @Override\n    public ProxyResponse handle(Request request, Response response)\n    {\n        if (response.getStatusCode() == NO_CONTENT.code()) {\n            return new ProxyResponse(response.getHeaders(), new byte[0]);\n        }\n\n        if (response.getStatusCode() != OK.code()) {\n            throw new ProxyException(format(\"Bad status code from remote Presto server: %s: %s\", response.getStatusCode(), readBody(response)));\n        }\n\n        String contentType = response.getHeader(CONTENT_TYPE);\n        if (contentType == null) {\n            throw new ProxyException(\"No Content-Type set in response from remote Presto server\");\n        }\n        if (!MediaType.parse(contentType).is(MEDIA_TYPE_JSON)) {\n            throw new ProxyException(\"Bad Content-Type from remote Presto server:\" + contentType);\n        }\n\n        try {\n            return new ProxyResponse(response.getHeaders(), toByteArray(response.getInputStream()));\n        }\n        catch (IOException e) {\n            throw new ProxyException(\"Failed reading response from remote Presto server\", e);\n        }\n    }\n\n    private static String readBody(Response response)\n    {\n        try {\n            return new String(toByteArray(response.getInputStream()), US_ASCII);\n        }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-proxy/src/main/java/com/facebook/presto/proxy/ProxyResponseHandler.java#L40-L76","documentation":"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.","triggerScenarios":"The remote server responded 200 OK but omitted the Content-Type header entirely on a proxied response.","commonSituations":"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.","solutions":["Inspect the actual raw response from the remote server (curl -v) to confirm the missing header.","Check for intermediaries stripping Content-Type and fix their configuration.","Ensure you are hitting the real Presto API endpoint, not a redirect or health page.","Upgrade/fix the backend component producing headerless responses."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// probe the endpoint and require a JSON content type\nconst probe = await fetch(backendUri + path, { headers });\nconst ct = probe.headers.get(\"content-type\");\nif (!ct || !ct.includes(\"application/json\")) throw new Error(\"Missing/unexpected Content-Type: \" + ct);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure load balancers/CDNs forward Content-Type headers untouched","Bypass SSO/auth gateways for service-to-service calls or send proper credentials","Confirm you target the Presto coordinator API, not a redirect or health endpoint","Add a startup smoke test asserting JSON responses from the backend"],"tags":["http","headers","content-type","proxy"],"backgroundTag":"missing-content-type-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"}