prestodb/presto · error · IllegalStateException
Response does not contain a JSON value
Error message
Response does not contain a JSON value
What it means
JsonResponse.getValue() returns the parsed JSON body, but only if the HTTP response successfully deserialized (hasValue == true). When the response could not be parsed or an exception occurred during fetch, the library stores the exception instead, and calling getValue() throws this IllegalStateException wrapping the underlying cause.
Solutions
- Always check hasValue() before calling getValue(), and inspect getException()/getResponseBody() when it is false.
- Inspect getResponseBody() to see what the server actually returned (HTML error page, empty body, etc.).
- Verify the coordinator URI, port, and any proxy in front of Presto are correct and healthy.
- Wrap the call in try-catch and use the cause (getException) to distinguish network failures from JSON parse failures.
Example fix
// before
QueryResults results = response.getValue(); // IllegalStateException when parse failed
// after
if (!response.hasValue()) {
throw new PrestoException("Non-JSON response: " + response.getResponseBody(), response.getException());
}
QueryResults results = response.getValue(); Defensive patterns
Strategy: try-catch
Validate before calling
if (!response.hasValue()) {
// do not call getValue(); inspect response.getException() and response.getResponseBody()
} Type guard
boolean hasJson = response != null && response.hasValue();
Try / catch
try { T value = response.getValue(); } catch (IllegalStateException e) { /* e.getCause() holds the parse/IO exception; fall back to response.getResponseBody() for diagnostics */ } Prevention
- Always gate getValue() behind hasValue()
- Log getResponseBody() when parsing fails to spot HTML gateway/proxy pages
- Verify coordinator URI/port and that no proxy is intercepting requests
- Handle non-200 statuses before consuming the JSON body
When it happens
Trigger: Calling getValue() on a JsonResponse created from a failed/failed-to-parse HTTP response — e.g. calling it after hasValue() returns false, or from StatementClientV1.advance/executePoll, getServerInfo, or testTransactionSupport paths when the coordinator returned non-JSON (HTML error page, empty body) or the request failed.
Common situations: Presto coordinator returning 502/503 gateway pages from a load balancer; hitting the wrong port (UI port vs coordinator port); proxy or auth redirects returning HTML; server crashes mid-query leaving an empty body.
Related errors
- Bad Content-Type from remote Presto server
- Illegal character ':' found in username
- Array reached maximum size
- Bad status code from remote Presto server
- cannot do sequential write after getFieldBlockBuilder is…
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/a4f6ea249b3fbc17.
Report an issue: GitHub.
Appendix: source
Thrown at presto-client/src/main/java/com/facebook/presto/client/JsonResponse.java:98
public String getStatusMessage()
{
return statusMessage;
}
public Headers getHeaders()
{
return headers;
}
public boolean hasValue()
{
return hasValue;
}
public T getValue()
{
if (!hasValue) {
throw new IllegalStateException("Response does not contain a JSON value", exception);
}
return value;
}
public String getResponseBody()
{
return responseBody;
}
@Nullable
public IllegalArgumentException getException()
{
return exception;
}
@Override
public String toString()
{View on GitHub (pinned to 55bb57d202)