{"record":{"id":"4ab4b3c7edf1a8d9","repo":"NationalSecurityAgency/ghidra","slug":"executable-category-already-exists-4ab4b3","errorCode":null,"errorMessage":"Executable category already exists","messagePattern":"Executable category already exists","errorType":"validation","errorClass":"LSHException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java","lineNumber":2936,"sourceCode":"\t\tif (!CategoryRecord.enforceTypeCharacters(query.type_name)) {\n\t\t\tthrow new LSHException(\"Bad characters in proposed category type\");\n\t\t}\n\t\tif (query.isdatecolumn) {\n\t\t\tinfo.dateColumnName = query.type_name;\n\t\t\tStringBuilder buffer = new StringBuilder();\n\t\t\tbuffer.append(\"{ \\\"type\\\": \\\"keyvalue\\\", \\\"value\\\": \\\"\")\n\t\t\t\t\t.append(info.dateColumnName)\n\t\t\t\t\t.append(\"\\\" }\");\n\t\t\tconnection.executeStatementNoResponse(ElasticConnection.PUT, \"configuration/datecolumn\",\n\t\t\t\tbuffer.toString());\n\t\t\tresponse.info = info;\n\t\t\treturn;\n\t\t}\n\t\t// Check for existing category\n\t\tif (info.execats != null) {\n\t\t\tfor (String cat : info.execats) {\n\t\t\t\tif (cat.equals(query.type_name)) {\n\t\t\t\t\tthrow new LSHException(\"Executable category already exists\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (info.execats == null) {\n\t\t\tinfo.execats = new ArrayList<>();\n\t\t}\n\t\tinfo.execats.add(query.type_name);\n\t\twriteExecutableCategories();\n\t\tresponse.info = info;\n\t}\n\n\t/**\n\t * Entry point for the Elasticsearch version of InstallTagRequest command:\n\t *   Install a new function tag to be managed by this data\n\t * @param query is command parameters\n\t * @throws LSHException if the command is misconfigured\n\t * @throws ElasticException for communication problems with the server\n\t */","sourceCodeStart":2918,"sourceCodeEnd":2954,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/elastic/ElasticDatabase.java#L2918-L2954","documentation":"fdbInstallCategory iterates info.execats; if query.type_name already equals an installed category it throws LSHException(\"Executable category already exists\") without modifying the database.","triggerScenarios":"Calling InstallCategory for a category name that is already registered in the database.","commonSituations":"Re-running a setup/install script; an idempotent installer that does not check existence first.","solutions":["Check existing categories before installing (or treat the 'already exists' outcome as success).","Choose a different, unique category name.","Drop then reinstall if a rename is required."],"exampleFix":"// before\ninstallCategory(db, name); // throws on re-run\n// after\nif (!db.getInfo().execats.contains(name)) {\n    installCategory(db, name);\n}","handlingStrategy":"validation","validationCode":"List<String> existing = db.getInfo().execats != null ? db.getInfo().execats : List.of();\nif (existing.contains(name)) return; // idempotent skip","typeGuard":"boolean alreadyInstalled = db.getInfo().execats != null && db.getInfo().execats.contains(name);","tryCatchPattern":"try { db.installCategory(req); }\ncatch (LSHException e) {\n    if (e.getMessage().equals(\"Executable category already exists\")) return;\n    throw e;\n}","preventionTips":["Make install scripts idempotent by checking info.execats first."],"tags":["bsim","category","duplicate","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}