{"record":{"id":"779843d88c8298c3","repo":"NationalSecurityAgency/ghidra","slug":"database-getlasterror-message","errorCode":null,"errorMessage":"{database.getLastError().message}","messagePattern":"\\{database\\.getLastError\\(\\)\\.message\\}","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java","lineNumber":146,"sourceCode":"\t */\n\tpublic boolean isConfigured() {\n\t\treturn (scorer.simThreshold > 0.0);\n\t}\n\n\t/**\n\t * Make sure the database has an active connection. Query for basic\n\t * information and inform the scorer of settings\n\t * @return information from the database\n\t * @throws LSHException if something is wrong with the connection\n\t */\n\tprivate DatabaseInformation pullConnectionInfo() throws LSHException {\n\t\tif (!database.initialize()) {\n\t\t\tthrow new LSHException(\"Unable to connect to server\");\n\t\t}\n\t\tQueryInfo query = new QueryInfo();\n\t\tResponseInfo response = query.execute(database);\n\t\tif (response == null) {\n\t\t\tthrow new LSHException(database.getLastError().message);\n\t\t}\n\t\tvectorFactory = database.getLSHVectorFactory();\n\t\treturn response.info;\n\t}\n\n\t/**\n\t * Look up a full ExecutableRecord in the database given an md5\n\t * @param md5 is the md5 String\n\t * @return the corresponding ExecutableRecord\n\t * @throws LSHException if there are problems accessing the database\n\t *    or the executable doesn't exist\n\t */\n\tprivate ExecutableRecord lookupExecutable(String md5) throws LSHException {\n\t\tQueryName query = new QueryName();\n\t\tquery.spec = new ExeSpecifier();\n\t\tquery.spec.exemd5 = md5;\n\t\tquery.maxfunc = 1;\n\t\tquery.fillinCallgraph = false;","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java#L128-L164","documentation":"Thrown by ExecutableComparison.pullConnectionInfo when a QueryInfo execute() returns a null response, indicating the query failed. The actual failure message is retrieved from database.getLastError().message. This wraps any server-side or protocol-level QueryInfo failure into an LSHException.","triggerScenarios":"database.initialize() succeeds but the subsequent QueryInfo (basic database metadata query) fails and returns null — e.g., protocol error, server-side exception, authentication succeeds but query permission fails, or the server returns a malformed response.","commonSituations":"Connected to a partially-initialized or corrupted BSim database; version mismatch between client and server; permission issues on the database; transient server error during the initial metadata fetch.","solutions":["Inspect db.getLastError().message for the specific underlying cause.","Verify client/server BSim protocol versions are compatible.","Recreate or repair the BSim database if metadata is corrupted.","Retry after resolving the reported server-side error."],"exampleFix":"// before\nDatabaseInformation info = cmp.pullConnectionInfo(); // opaque failure\n// after (wrap to expose detail)\nQueryInfo q = new QueryInfo();\nResponseInfo r = q.execute(database);\nif (r == null) {\n    throw new RuntimeException(\"QueryInfo failed: \" + database.getLastError().message);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (LSHException e) { String msg = e.getMessage(); log.error(\"QueryInfo failed: {}\", msg); /* msg == db.getLastError().message; diagnose and surface to user */ }","preventionTips":["Log db.getLastError() after any null query response to capture the root cause.","Ensure client and server BSim versions match to avoid protocol errors.","Validate database integrity with QueryInfo during health checks."],"tags":["bsim","network","database","query-failure"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}