NationalSecurityAgency/ghidra · critical · ElasticException

Unrecoverable error: Could not find configuration

Error message

Unrecoverable error: Could not find configuration

What it means

Thrown in readKeyValues when the configuration index exists (no index_not_found_exception) but the match_all search returns total <= 1 documents. A properly initialized database has at least 6 key/value documents (name, owner, description, major, minor, settings) plus a sequence document. Having 0 or 1 documents means the configuration index was created but writeBasicInfo never completed or was partially destroyed.

Source

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

		JsonObject resp;
		try {
			resp = connection.executeStatement(ElasticConnection.GET, "configuration/_search",
				buffer.toString());
		}
		catch (ElasticException ex) {
			if (ex.getMessage().contains("index_not_found_exception")) {
				throw new NoDatabaseException("Database instance does not exist");
			}
			throw ex;
		}
		JsonObject baseHits = (JsonObject) resp.get("hits");
		long total = 0;
		if (baseHits != null) {
			JsonObject totalRec = (JsonObject) baseHits.get("total");
			total = totalRec.get("value").getAsLong();
		}
		if (total <= 1) {
			throw new ElasticException("Unrecoverable error: Could not find configuration");
		}
		HashMap<String, String> res = new HashMap<>();
		JsonArray hits = (JsonArray) baseHits.get("hits");
		for (JsonElement hit2 : hits) {
			JsonObject hit = (JsonObject) hit2;
			String key = hit.get("_id").getAsString();
			JsonObject source = (JsonObject) hit.get("_source");
			JsonElement value = source.get("value");
			if (ElasticConnection.isNull(value)) {
				continue;		// This might be the "sequence" document
			}
			res.put(key, value.getAsString());
		}
		return res;
	}

	/**
	 * Given a critical key in the database configuration, return its corresponding value

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Drop the database (dropDatabase) and recreate it from scratch using the generate command, ensuring it runs to completion.
  2. If data must be preserved, manually inspect the configuration index and re-add the missing key/value documents (name, owner, description, major, minor, settings) via Elasticsearch bulk indexing.
  3. Ensure the generate/create command is not interrupted; check server logs for write failures.
  4. Verify the configuration index document count via curl GET <repo>_configuration/_count before attempting initialize.
Defensive patterns

Strategy: fallback

Validate before calling

// Check configuration document count before initializing
JsonObject countResp = connection.executeURIOnly(ElasticConnection.GET,
    "configuration/_count");
long count = countResp.get("count").getAsLong();
if (count <= 1) {
    throw new IllegalStateException(
        "Configuration index exists but is incomplete (" + count + " docs). Database may be corrupted.");
}

Try / catch

try {
    database.initialize();
} catch (ElasticException e) {
    if (e.getMessage().contains("Could not find configuration")) {
        // Database is corrupted — recreate from scratch
        Msg.error(this, "Database configuration is incomplete; recreating: " + e.getMessage());
        database.recreate(config); // drop + generate
    }
    throw e;
}

Prevention

When it happens

Trigger: During initialize() -> readBasicInfo -> readKeyValues. The configuration/_search match_all query succeeds (index exists) but total hits are 0 or 1. The check total <= 1 fails because critical configuration was never written or was deleted.

Common situations: Database creation was interrupted after createConfigurationIndex but before writeBasicInfo finished; partial database drop that left an empty configuration index; manual deletion of configuration documents; a failed or crashed generate command.

Related errors


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