NationalSecurityAgency/ghidra · error · LSHException
Could not perform query on vector
Error message
Could not perform query on vector
What it means
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.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/ExecutableComparison.java:297
* @param workList is the current list of IDs yet to be processed for the cluster
* @param threshold defines how similar "close" vectors are
* @return the VectorResult of the next ID
* @throws LSHException if something goes wrong during a query
*/
private VectorResult queryVectorForCluster(TreeMap<Long, VectorResult> workList,
double threshold)
throws LSHException {
Entry<Long, VectorResult> entry = workList.pollFirstEntry();
VectorResult currentVector = entry.getValue();
baseIds.remove(entry.getKey()); // Look-up vector and remove from to-do list
queriedIds.add(entry.getKey()); // Mark that this id has been queried
if (currentVector == null) {
currentVector = buildSeedVector(entry.getKey()); // If VectorResult isn't present, this must be a seed for the cluster
}
QueryNearestVector query = buildVectorQuery(currentVector.vec, threshold);
ResponseNearestVector response = query.execute(database);
if (response == null || response.result.size() != 1) {
throw new LSHException("Could not perform query on vector");
}
Iterator<VectorResult> iter = response.result.get(0).iterator();
while (iter.hasNext()) {
VectorResult vecResult = iter.next();
Long curId = vecResult.vectorid;
if (queriedIds.contains(curId)) {
continue; // Already queried
}
workList.put(curId, vecResult);
}
return currentVector;
}
/**
* Starting with the first vector in -vectorMap- build the cluster of vectors that are within
* a given -threshold- of each other. The cluster is the "connected" component containing the
* first vector, where two vectors are "connected" if they are similar to each other within
* the threshold. View on GitHub (pinned to d5f144c24d)
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.
Example fix
// before
VectorResult cur = processNextVectorInCluster(workList, ...); // throws
// after
ResponseNearestVector resp = query.execute(database);
if (resp == null || resp.result.size() != 1) {
String detail = resp == null ? database.getLastError().message : "unexpected result size";
log.warn("Nearest vector query failed: {}", detail);
continue; // skip this vector in the cluster
} Defensive patterns
Strategy: retry
Try / catch
catch (LSHException e) { if (e.getMessage().contains("Could not perform query")) { /* log getLastError, retry once after reconnect, else skip vector */ } } Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- {database.getLastError().message}
- Couldn't open remote program: {} for {}.
- Could not start postgres server process
- Error querying vectorid:
- No functions matching vectorid:
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/bee586b88244678a.
Report an issue: GitHub.