{"record":{"id":"01a5a11efad9a1b7","repo":"NationalSecurityAgency/ghidra","slug":"error-parsing-response-message","errorCode":null,"errorMessage":"Error parsing response: {message}","messagePattern":"Error parsing response: (.+?)","errorType":"exception","errorClass":"ElasticException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java","lineNumber":212,"sourceCode":"\t\t\tconnection.setDoOutput(true);\n\t\t\ttry (Writer writer = new OutputStreamWriter(connection.getOutputStream())) {\n\t\t\t\twriter.write(body);\n\t\t\t}\n\t\t\tlastResponseCode = connection.getResponseCode();\n\t\t\tJsonObject resp = grabResponse(connection);\n\t\t\tif (!lastRequestSuccessful()) {\n\t\t\t\tthrow new ElasticException(parseErrorJSON(resp));\n\t\t\t}\n\t\t\treturn resp;\n\t\t}\n\t\tcatch (URISyntaxException e) {\n\t\t\tthrow new ElasticException(\"Error parsing URL: \" + e.getMessage());\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new ElasticException(\"Error sending request: \" + e.getMessage());\n\t\t}\n\t\tcatch (JsonParseException e) {\n\t\t\tthrow new ElasticException(\"Error parsing response: \" + e.getMessage());\n\t\t}\n\t\tfinally {\n\t\t\tif (connection != null) {\n\t\t\t\tconnection.disconnect();\n\t\t\t}\n\t\t}\n\n\t}\n\n\t/**\n\t * Execute an elasticsearch command where we are not expecting a response\n\t * @param command is the type of the command\n\t * @param path is the overarching {@code index/type/<command>}\n\t * @param body is the JSON document describing the request\n\t * @throws ElasticException for any problems with the connecting\n\t */\n\tpublic void executeStatementNoResponse(String command, String path, String body)\n\t\t\tthrows ElasticException {","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java#L194-L230","documentation":"Thrown by ElasticConnection.executeRawStatement when JsonParser.parseReader fails to parse the response body as a JsonObject (JsonParseException). The HTTP call succeeded but the body is not valid JSON or not a JSON object, so grabResponse's getAsJsonObject() / parse fails.","triggerScenarios":"executeRawStatement where the response body is empty, is HTML (e.g. a proxy error page), is malformed JSON, or is a JSON array/scalar rather than an object. grabResponse parses then calls getAsJsonObject(), which throws on non-object.","commonSituations":"A reverse proxy/load balancer returning an HTML error page instead of JSON; truncated response body; wrong endpoint returning a non-JSON payload; response encoding issues; an ES plugin intercepting the request.","solutions":["Verify the hostURL actually points at Elasticsearch (and not a proxy returning HTML).","Capture the raw response body (e.g. via curl) to confirm it is a JSON object.","Check for an intermediate proxy/gateway and bypass or configure it correctly.","Ensure the ES endpoint path is correct for the command issued."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return conn.executeRawStatement(command, path, body);\n} catch (ElasticException e) {\n    if (e.getMessage().startsWith(\"Error parsing response\")) {\n        // capture raw body via curl to confirm it is JSON; check for proxy\n    } else throw e;\n}","preventionTips":["Point hostURL directly at Elasticsearch, not an HTML-serving proxy.","Confirm endpoints return JSON objects with curl before integrating.","Bypass or configure reverse proxies/gateways correctly."],"tags":["bsim","elastic","json","parsing","network","java"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}