{"record":{"id":"47d7a2343ebfbf87","repo":"NationalSecurityAgency/ghidra","slug":"unrecoverable-error-could-not-find-configuration","errorCode":null,"errorMessage":"Unrecoverable error: Could not find configuration","messagePattern":"Unrecoverable error: Could not find configuration","errorType":"exception","errorClass":"ElasticException","httpStatus":null,"severity":"critical","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java","lineNumber":2115,"sourceCode":"\t\tJsonObject resp;\n\t\ttry {\n\t\t\tresp = connection.executeStatement(ElasticConnection.GET, \"configuration/_search\",\n\t\t\t\tbuffer.toString());\n\t\t}\n\t\tcatch (ElasticException ex) {\n\t\t\tif (ex.getMessage().contains(\"index_not_found_exception\")) {\n\t\t\t\tthrow new NoDatabaseException(\"Database instance does not exist\");\n\t\t\t}\n\t\t\tthrow ex;\n\t\t}\n\t\tJsonObject baseHits = (JsonObject) resp.get(\"hits\");\n\t\tlong total = 0;\n\t\tif (baseHits != null) {\n\t\t\tJsonObject totalRec = (JsonObject) baseHits.get(\"total\");\n\t\t\ttotal = totalRec.get(\"value\").getAsLong();\n\t\t}\n\t\tif (total <= 1) {\n\t\t\tthrow new ElasticException(\"Unrecoverable error: Could not find configuration\");\n\t\t}\n\t\tHashMap<String, String> res = new HashMap<>();\n\t\tJsonArray hits = (JsonArray) baseHits.get(\"hits\");\n\t\tfor (JsonElement hit2 : hits) {\n\t\t\tJsonObject hit = (JsonObject) hit2;\n\t\t\tString key = hit.get(\"_id\").getAsString();\n\t\t\tJsonObject source = (JsonObject) hit.get(\"_source\");\n\t\t\tJsonElement value = source.get(\"value\");\n\t\t\tif (ElasticConnection.isNull(value)) {\n\t\t\t\tcontinue;\t\t// This might be the \"sequence\" document\n\t\t\t}\n\t\t\tres.put(key, value.getAsString());\n\t\t}\n\t\treturn res;\n\t}\n\n\t/**\n\t * Given a critical key in the database configuration, return its corresponding value","sourceCodeStart":2097,"sourceCodeEnd":2133,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java#L2097-L2133","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Drop the database (dropDatabase) and recreate it from scratch using the generate command, ensuring it runs to completion.","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.","Ensure the generate/create command is not interrupted; check server logs for write failures.","Verify the configuration index document count via curl GET <repo>_configuration/_count before attempting initialize."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Check configuration document count before initializing\nJsonObject countResp = connection.executeURIOnly(ElasticConnection.GET,\n    \"configuration/_count\");\nlong count = countResp.get(\"count\").getAsLong();\nif (count <= 1) {\n    throw new IllegalStateException(\n        \"Configuration index exists but is incomplete (\" + count + \" docs). Database may be corrupted.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    database.initialize();\n} catch (ElasticException e) {\n    if (e.getMessage().contains(\"Could not find configuration\")) {\n        // Database is corrupted — recreate from scratch\n        Msg.error(this, \"Database configuration is incomplete; recreating: \" + e.getMessage());\n        database.recreate(config); // drop + generate\n    }\n    throw e;\n}","preventionTips":["Ensure the generate command runs to completion without interruption.","After creation, verify the configuration index has at least 7 documents (6 key/values + sequence).","Back up the database or maintain source executables for re-ingestion in case of corruption."],"tags":["elasticsearch","bsim","initialization","data-corruption","configuration","partial-init"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}