NationalSecurityAgency/ghidra · error · ElasticException

Error querying vectorid:

Error message

Error querying vectorid: 

What it means

Thrown in queryNearest when queryVectorIdMatch returns null for a given vector id. This is a defensive guard: in the current implementation queryVectorIdMatch (line 776) never returns null — it returns an empty JsonArray when total==0, or a non-null hitsArray otherwise, or throws an ElasticException on connection failure. The check is effectively unreachable dead code.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java:950

			similarityResult.setTotalCount((int) queryNearestVector(resultset, vector, query.thresh,
				query.signifthresh, vectormax));

			// Put the new results in the map so we can use them if another 
			// similar vector comes along.
			vecToResultsMap.put(vector, resultset);
		}

		int count = 0;

		for (VectorResult dresult : resultset) {
			if (count >= query.max) {
				break;
			}
			final SignatureRecord srec = manager.newSignature(dresult.vec, dresult.hitcount);
			JsonArray descres;
			descres = queryVectorIdMatch(dresult.vectorid, filter, query.max - count);
			if (descres == null) {
				throw new ElasticException(
					"Error querying vectorid: " + Long.toString(dresult.vectorid));
			}
			if (descres.size() == 0) {
				if (filter != null) {
					continue; // Filter may have eliminated all results
				}
				// Otherwise this is a sign of corruption in the database
				throw new ElasticException(
					"No functions matching vectorid: " + Long.toString(dresult.vectorid));
			}
			count += descres.size();
			convertDescriptionRows(similarityResult, descres, dresult, manager, srec);
		}
	}

	/**
	 * Perform a full QueryNearest request, with additional filters, placing SimilarityResults
	 * in the ResponseNearest object. An iterator to FunctionDescriptions determines what

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Treat this as a code-defect signal: inspect queryVectorIdMatch for any branch that could return null, especially in a custom fork.
  2. If using the stock Ghidra code, report as a bug since the guard is unreachable and queryVectorIdMatch should be audited for contract compliance.
  3. As a workaround, ensure queryVectorIdMatch always returns a non-null JsonArray before reaching this call site.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    database.query(queryNearest);
} catch (ElasticException e) {
    if (e.getMessage().startsWith("Error querying vectorid:")) {
        // Defensive guard — should not occur in stock code; report as a bug
        Msg.error(this, "Unexpected null from queryVectorIdMatch — possible code regression: " + e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: Would only trigger if queryVectorIdMatch were modified in a fork to return null on some code path. As written, queryVectorIdMatch either returns a JsonArray (possibly empty) or propagates an ElasticException from connection.executeStatement.

Common situations: Not expected to occur with the shipped code. If observed, it indicates a custom modification to queryVectorIdMatch that introduced a null return path.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/048b7ed56de90bc2. Report an issue: GitHub.