{"record":{"id":"5b0bdbdf9e479219","repo":"NationalSecurityAgency/ghidra","slug":"type-reason","errorCode":null,"errorMessage":"{type} : {reason}","messagePattern":"\\{type\\} : \\{reason\\}","errorType":"http","errorClass":"ElasticException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java","lineNumber":201,"sourceCode":"\t * @return the response as parsed JsonObject\n\t * @throws ElasticException for any problems with the connection\n\t */\n\tpublic JsonObject executeRawStatement(String command, String path, String body)\n\t\t\tthrows ElasticException {\n\t\tHttpURLConnection connection = null;\n\t\ttry {\n\t\t\tURL httpURL = new URI(hostURL + path).toURL();\n\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\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","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticConnection.java#L183-L219","documentation":"Thrown by ElasticConnection.executeRawStatement when the HTTP request completed but Elasticsearch returned a non-success status (lastRequestSuccessful() is false). The error message is built by parseErrorJSON, which extracts 'type' and 'reason' from the ES error JSON document as '<type> : <reason>'. This is the primary Elasticsearch-side error surface for raw statements.","triggerScenarios":"executeRawStatement(command, path, body) where the response code is an error (4xx/5xx) and ES returns an error JSON with type/reason fields. Examples: invalid index/mapping, malformed query body, version conflicts, mapper exceptions, script errors.","commonSituations":"Wrong index name or missing mapping; malformed JSON body; field type conflicts; cluster overloaded/RED status; insufficient disk/watermark; authentication/authorization failure surfacing as an ES error; versioning conflicts on concurrent writes.","solutions":["Read the full 'type : reason' and any logged parseErrorCause detail to identify the ES error class.","Correct the request body/path/index per the ES error type (e.g. fix mapping, fix JSON syntax).","Check cluster health (_cluster/health) and resolve RED/yellow issues (shards, disk watermark).","Verify credentials/permissions if the error type indicates security/authorization."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    return conn.executeRawStatement(command, path, body);\n} catch (ElasticException e) {\n    String m = e.getMessage();\n    if (m.contains(\"mapper_parsing\") || m.contains(\"illegal_argument\")) {\n        // fix body/path and retry\n    } else throw e;\n}","preventionTips":["Validate request body JSON and index/mapping before sending.","Keep the ES cluster green and monitor shard/disk health.","Inspect parseErrorCause detail logged for *_exception types."],"tags":["bsim","elastic","elasticsearch-error","network","java"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}