{"record":{"id":"bee586b88244678a","repo":"NationalSecurityAgency/ghidra","slug":"could-not-perform-query-on-vector","errorCode":null,"errorMessage":"Could not perform query on vector","messagePattern":"Could not perform query on vector","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java","lineNumber":297,"sourceCode":"\t * @param workList is the current list of IDs yet to be processed for the cluster\n\t * @param threshold defines how similar \"close\" vectors are\n\t * @return the VectorResult of the next ID\n\t * @throws LSHException if something goes wrong during a query\n\t */\n\tprivate VectorResult queryVectorForCluster(TreeMap<Long, VectorResult> workList,\n\t\tdouble threshold)\n\t\tthrows LSHException {\n\t\tEntry<Long, VectorResult> entry = workList.pollFirstEntry();\n\t\tVectorResult currentVector = entry.getValue();\n\t\tbaseIds.remove(entry.getKey());\t\t// Look-up vector and remove from to-do list\n\t\tqueriedIds.add(entry.getKey());\t\t// Mark that this id has been queried\n\t\tif (currentVector == null) {\n\t\t\tcurrentVector = buildSeedVector(entry.getKey());\t// If VectorResult isn't present, this must be a seed for the cluster\n\t\t}\n\t\tQueryNearestVector query = buildVectorQuery(currentVector.vec, threshold);\n\t\tResponseNearestVector response = query.execute(database);\n\t\tif (response == null || response.result.size() != 1) {\n\t\t\tthrow new LSHException(\"Could not perform query on vector\");\n\t\t}\n\t\tIterator<VectorResult> iter = response.result.get(0).iterator();\n\t\twhile (iter.hasNext()) {\n\t\t\tVectorResult vecResult = iter.next();\n\t\t\tLong curId = vecResult.vectorid;\n\t\t\tif (queriedIds.contains(curId)) {\n\t\t\t\tcontinue;\t// Already queried\n\t\t\t}\n\t\t\tworkList.put(curId, vecResult);\n\t\t}\n\t\treturn currentVector;\n\t}\n\n\t/**\n\t * Starting with the first vector in -vectorMap- build the cluster of vectors that are within\n\t * a given -threshold- of each other. The cluster is the \"connected\" component containing the\n\t * first vector, where two vectors are \"connected\" if they are similar to each other within\n\t * the threshold. ","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java#L279-L315","documentation":"Thrown by ExecutableComparison.processNextVectorInCluster when a QueryNearestVector (similarity search) returns null or a result set whose size is not exactly 1. This indicates the nearest-neighbor query for a given vector failed or returned an unexpected number of result groups.","triggerScenarios":"Executing a QueryNearestVector for a vector during cluster expansion and the response is null (query failure) or result.size() != 1 (unexpected result structure — should be exactly one result group per queried vector).","commonSituations":"Connection drop mid-clustering; server-side similarity index error; vector format/length mismatch with the database's LSH configuration; corrupted vector data; transient server overload.","solutions":["Inspect db.getLastError() if the response was null for the specific server error.","Verify the vector's LSH parameters (k, L, weights) match the database configuration.","Retry on transient failures; reconnect if the session was dropped.","Check for data corruption if the error is persistent for a specific vector."],"exampleFix":"// before\nVectorResult cur = processNextVectorInCluster(workList, ...); // throws\n// after\nResponseNearestVector resp = query.execute(database);\nif (resp == null || resp.result.size() != 1) {\n    String detail = resp == null ? database.getLastError().message : \"unexpected result size\";\n    log.warn(\"Nearest vector query failed: {}\", detail);\n    continue; // skip this vector in the cluster\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (LSHException e) { if (e.getMessage().contains(\"Could not perform query\")) { /* log getLastError, retry once after reconnect, else skip vector */ } }","preventionTips":["Log db.getLastError() immediately when nearest-vector queries fail.","Ensure the vector factory configuration matches the database before querying.","Implement skip-and-continue for individual vector failures in large clustering jobs."],"tags":["bsim","network","vector","query-failure"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}