{"record":{"id":"a4f6ea249b3fbc17","repo":"prestodb/presto","slug":"response-does-not-contain-a-json-value","errorCode":null,"errorMessage":"Response does not contain a JSON value","messagePattern":"Response does not contain a JSON value","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-client/src/main/java/com/facebook/presto/client/JsonResponse.java","lineNumber":98,"sourceCode":"    public String getStatusMessage()\n    {\n        return statusMessage;\n    }\n\n    public Headers getHeaders()\n    {\n        return headers;\n    }\n\n    public boolean hasValue()\n    {\n        return hasValue;\n    }\n\n    public T getValue()\n    {\n        if (!hasValue) {\n            throw new IllegalStateException(\"Response does not contain a JSON value\", exception);\n        }\n        return value;\n    }\n\n    public String getResponseBody()\n    {\n        return responseBody;\n    }\n\n    @Nullable\n    public IllegalArgumentException getException()\n    {\n        return exception;\n    }\n\n    @Override\n    public String toString()\n    {","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-client/src/main/java/com/facebook/presto/client/JsonResponse.java#L80-L116","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nQueryResults results = response.getValue(); // IllegalStateException when parse failed\n// after\nif (!response.hasValue()) {\n    throw new PrestoException(\"Non-JSON response: \" + response.getResponseBody(), response.getException());\n}\nQueryResults results = response.getValue();","handlingStrategy":"try-catch","validationCode":"if (!response.hasValue()) {\n    // do not call getValue(); inspect response.getException() and response.getResponseBody()\n}","typeGuard":"boolean hasJson = response != null && response.hasValue();","tryCatchPattern":"try { T value = response.getValue(); } catch (IllegalStateException e) { /* e.getCause() holds the parse/IO exception; fall back to response.getResponseBody() for diagnostics */ }","preventionTips":["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"],"tags":["http","json","presto-client","illegal-state","response-parsing"],"backgroundTag":"non-json-response","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"}