prestodb/presto · error · PrestoException
REST_SERVER_BAD_RESPONSE
REST_SERVER_BAD_RESPONSE
Error message
Unexpected response code:
What it means
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.
Source
Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java:186
else if (exception instanceof java.net.ConnectException) {
throw new PrestoException(REST_SERVER_CONNECT_ERROR, "Failed to connect to REST server. Request: " + request, exception);
}
else {
throw new PrestoException(REST_SERVER_ERROR, "Unexpected error during REST call. Request: " + request + ", Exception: " + exception.getMessage(), exception);
}
}
@Override
public SqlFunctionResult handle(Request request, Response response)
{
if (response.getStatusCode() == HTTP_NOT_FOUND) {
throw new PrestoException(REST_SERVER_NOT_FOUND, "Resource not found on REST server. Request: " + request);
}
else if (response.getStatusCode() == HTTP_SERVER_ERROR) {
throw new PrestoException(REST_SERVER_ERROR, "Internal server error on REST server. Request: " + request);
}
else if (response.getStatusCode() != HTTP_OK) {
throw new PrestoException(REST_SERVER_BAD_RESPONSE, "Unexpected response code: " + response.getStatusCode() + ". Request: " + request);
}
try {
SliceInput input = new InputStreamSliceInput(response.getInputStream());
SerializedPage serializedPage = readSerializedPage(input);
Page page = pageSerde.deserialize(serializedPage);
checkArgument(page.getChannelCount() == 1, "Expected only one channel in the function output");
SqlFunctionResult output = new SqlFunctionResult(page.getBlock(0), 1);
return output;
}
catch (IOException e) {
throw new PrestoException(REST_SERVER_IO_ERROR, "Error deserializing REST server response: " + e.getMessage(), e);
}
}
}
public static class SqlResultFutureCallback
implements FutureCallback<SqlFunctionResult>View on GitHub (pinned to 55bb57d202)
Solutions
- Check the failing status code and request URI
- Fix authentication/proxy issues causing unexpected 4xx responses
- Verify REST API version compatibility
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-function-namespace-managers/src/main/java/com/facebook/presto/functionNamespace/rest/RestSqlFunctionExecutor.java:186 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/89d9d1d5c6ceeb73.
Report an issue: GitHub.