{"record":{"id":"89d9d1d5c6ceeb73","repo":"prestodb/presto","slug":"rest-server-bad-response","errorCode":"REST_SERVER_BAD_RESPONSE","errorMessage":"Unexpected response code: ","messagePattern":"Unexpected response code: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java","lineNumber":186,"sourceCode":"            else if (exception instanceof java.net.ConnectException) {\n                throw new PrestoException(REST_SERVER_CONNECT_ERROR, \"Failed to connect to REST server. Request: \" + request, exception);\n            }\n            else {\n                throw new PrestoException(REST_SERVER_ERROR, \"Unexpected error during REST call. Request: \" + request + \", Exception: \" + exception.getMessage(), exception);\n            }\n        }\n\n        @Override\n        public SqlFunctionResult handle(Request request, Response response)\n        {\n            if (response.getStatusCode() == HTTP_NOT_FOUND) {\n                throw new PrestoException(REST_SERVER_NOT_FOUND, \"Resource not found on REST server. Request: \" + request);\n            }\n            else if (response.getStatusCode() == HTTP_SERVER_ERROR) {\n                throw new PrestoException(REST_SERVER_ERROR, \"Internal server error on REST server. Request: \" + request);\n            }\n            else if (response.getStatusCode() != HTTP_OK) {\n                throw new PrestoException(REST_SERVER_BAD_RESPONSE, \"Unexpected response code: \" + response.getStatusCode() + \". Request: \" + request);\n            }\n\n            try {\n                SliceInput input = new InputStreamSliceInput(response.getInputStream());\n                SerializedPage serializedPage = readSerializedPage(input);\n                Page page = pageSerde.deserialize(serializedPage);\n                checkArgument(page.getChannelCount() == 1, \"Expected only one channel in the function output\");\n                SqlFunctionResult output = new SqlFunctionResult(page.getBlock(0), 1);\n                return output;\n            }\n            catch (IOException e) {\n                throw new PrestoException(REST_SERVER_IO_ERROR, \"Error deserializing REST server response: \" + e.getMessage(), e);\n            }\n        }\n    }\n\n    public static class SqlResultFutureCallback\n            implements FutureCallback<SqlFunctionResult>","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java#L168-L204","documentation":"Raised in the REST executor's response handler when the function-namespace server answers with a status code the executor does not recognize as success for the request it sent. The unexpected status code and request details are appended, indicating a protocol mismatch or server-side failure rather than a client bug.","triggerScenarios":"Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java:186 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the failing status code and request URI","Fix authentication/proxy issues causing unexpected 4xx responses","Verify REST API version compatibility"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}