{"record":{"id":"f46a6f372a1bb423","repo":"prestodb/presto","slug":"rest-server-error","errorCode":"REST_SERVER_ERROR","errorMessage":"Unexpected error during REST call. Request: ","messagePattern":"Unexpected error during REST call\\. Request: ","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":172,"sourceCode":"                functionVersion);\n\n        return URI.create(String.format(\"%s%s\", baseUri, path));\n    }\n\n    public static class SqlFunctionResultResponseHandler\n            implements ResponseHandler<SqlFunctionResult, RuntimeException>\n    {\n        @Override\n        public SqlFunctionResult handleException(Request request, Exception exception)\n        {\n            if (exception instanceof java.net.SocketTimeoutException) {\n                throw new PrestoException(REST_SERVER_TIMEOUT, \"Request to REST server timed out. Request: \" + request, exception);\n            }\n            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());","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java#L154-L190","documentation":"Catch-all branch of handleException: any exception other than timeout or connect failure (DNS errors, TLS problems, client bugs) during the REST function call is wrapped in this generic REST_SERVER_ERROR PrestoException.","triggerScenarios":"Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java:172 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the nested exception for the root cause","Check REST server logs for the corresponding failure","Verify request URI and function version parameters"],"exampleFix":null,"handlingStrategy":"try-catch","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"}