{"record":{"id":"c41c5db4a9e8ba5e","repo":"NationalSecurityAgency/ghidra","slug":"could-not-locate-vector-by-id","errorCode":null,"errorMessage":"Could not locate vector by id","messagePattern":"Could not locate vector by id","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java","lineNumber":270,"sourceCode":"\t\tquery.manage.attachSignature(function, signature);\n\n\t\tquery.manage.transferSettings(scorer.executableSet);\n\t\tquery.thresh = threshold;\n\t\treturn query;\n\t}\n\n\t/**\n\t * Look up a single vector by id\n\t * @param id is the Long id of the vector\n\t * @return the matching vector result\n\t * @throws LSHException if the vector does not exist\n\t */\n\tprivate VectorResult buildSeedVector(Long id) throws LSHException {\n\t\tQueryVectorId query = new QueryVectorId();\n\t\tquery.vectorIds.add(id);\n\t\tResponseVectorId response = query.execute(database);\n\t\tif (response == null || response.vectorResults.size() != 1) {\n\t\t\tthrow new LSHException(\"Could not locate vector by id\");\n\t\t}\n\t\treturn response.vectorResults.get(0);\n\t}\n\n\t/**\n\t * Pull one ID out of the workList, look-up its corresponding vector, and query for nearby vectors.\n\t * Add IDs of the close vectors (that have not been seen before) to the workList\n\t * Use vectorMap to keep track of what's been seen/queried before\n\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();","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java#L252-L288","documentation":"Thrown by ExecutableComparison.buildSeedVector when a QueryVectorId query for a single vector id returns null or does not contain exactly one result. This means the vector id could not be resolved to a concrete vector — the id may be stale, the vector deleted, or a query failure occurred.","triggerScenarios":"Looking up a vector by id (QueryVectorId) where the id is no longer present in the database, or the query fails. Called when building a seed vector for a cluster and the VectorResult was not already cached in the work list.","commonSituations":"Stale vector id references after functions/executables were deleted from the database; concurrent modification (deletion during a comparison run); corrupted id index; transient query failure.","solutions":["Verify the vector id still exists before building the seed (re-query or check id validity).","Skip stale ids in cluster processing rather than failing.","Ensure no concurrent deletions occur during active comparisons.","Inspect db.getLastError() if the response was null (query failure)."],"exampleFix":"// before\nVectorResult v = buildSeedVector(id); // throws if id stale\n// after\nQueryVectorId q = new QueryVectorId();\nq.vectorIds.add(id);\nResponseVectorId resp = q.execute(database);\nif (resp == null || resp.vectorResults.size() != 1) {\n    return null; // skip stale id\n}","handlingStrategy":"validation","validationCode":"// Before seeding, verify id liveness:\nQueryVectorId q = new QueryVectorId();\nq.vectorIds.add(id);\nResponseVectorId resp = q.execute(database);\nif (resp != null && resp.vectorResults.size() == 1) {\n    // safe to proceed\n} else { /* skip id */ }","typeGuard":null,"tryCatchPattern":"catch (LSHException e) { if (e.getMessage().contains(\"Could not locate vector\")) { /* skip this id, continue clustering */ } }","preventionTips":["Avoid concurrent database deletions during active comparisons.","Handle stale ids gracefully in clustering loops.","Refresh id sets after major database modifications."],"tags":["bsim","data","vector","stale-reference"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}