{"record":{"id":"454b5e16b28ff70d","repo":"NationalSecurityAgency/ghidra","slug":"error-parsing-response","errorCode":null,"errorMessage":"Error parsing response: ","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":338,"sourceCode":"\t\t\tconnection = (HttpURLConnection) httpURL.openConnection();\n\t\t\tconnection.setRequestMethod(command);\n\t\t\tconnection.setRequestProperty(\"Content-Type\", \"application/json\");\n\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\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\t}\n\n\t/**\n\t * Send a bulk request to the elasticsearch server.  This is a special format for combining multiple commands\n\t * and is structured slightly differently from other commands.\n\t * @param path is the specific URL path receiving the bulk command\n\t * @param body is structured list of JSON commands and source\n\t * @return the response as parsed JsonObject\n\t * @throws ElasticException for any problems with the connection\n\t */\n\tpublic JsonObject executeBulk(String path, String body) throws ElasticException {\n\t\tHttpURLConnection connection = null;","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java#L320-L356","documentation":"JsonParseException handler inside executeStatementExpectFailure. The method tolerates ES HTTP errors, so this fires only when the body that came back is not parseable JSON (HTML proxy page, captive portal, truncated response, or a non-ES endpoint).","triggerScenarios":"executeStatementExpectFailure receives HTML from a reverse proxy (502/503) or an intercepting portal instead of JSON; response truncated by a proxy body limit; base URL hits a non-ES service.","commonSituations":"ES behind a proxy that returns an HTML maintenance page under load; wrong base URL; misconfigured TLS terminating at a different service.","solutions":["Confirm the endpoint is ES: curl <url>/ returns JSON cluster info.","Raise or remove proxy response buffering/body-size limits for the ES route.","Fail fast before probing if a preflight root GET is not JSON."],"exampleFix":"// before\nJsonObject r = c.executeStatementExpectFailure(ElasticConnection.GET, idx, body);\n// after\nif (!isElastic(c)) throw new IllegalStateException(\"not an ES endpoint\");\nJsonObject r = c.executeStatementExpectFailure(ElasticConnection.GET, idx, body);","handlingStrategy":"try-catch","validationCode":"public static boolean returnsJson(String url) {\n    try { Reader r = new InputStreamReader(URI.create(url).toURL().openStream());\n          JsonParser.parseReader(r); return true; }\n    catch (Exception e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return conn.executeStatementExpectFailure(cmd, path, body);\n} catch (ElasticException e) {\n    if (e.getMessage().startsWith(\"Error parsing response\"))\n        throw new IllegalStateException(\"Non-JSON response during probe; verify ES endpoint/proxy\", e);\n    throw e;\n}","preventionTips":["Ensure the ES route through any proxy returns JSON, not HTML.","Confirm base URL points at ES before probing.","Raise proxy reply-size limits for ES responses."],"tags":["json","parsing","network","bsim"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}