{"record":{"id":"839eac86af334f36","repo":"NationalSecurityAgency/ghidra","slug":"unable-to-parse-configuration-template","errorCode":null,"errorMessage":"Unable to parse configuration template","messagePattern":"Unable to parse configuration template","errorType":"exception","errorClass":"LSHException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java","lineNumber":318,"sourceCode":"\t\t}\n\t\treturn res;\n\t}\n\n\tpublic static Configuration loadConfigurationTemplate(String configname) throws LSHException {\n\t\tResourceFile moduleDataSubDirectory;\n\t\tfinal Configuration config = new Configuration();\n\t\ttry {\n\t\t\tmoduleDataSubDirectory = Application.getModuleDataSubDirectory(\"\");\n\t\t\tconfig.loadTemplate(moduleDataSubDirectory, configname);\n\t\t}\n\t\tcatch (final FileNotFoundException e) {\n\t\t\tthrow new LSHException(\"Missing configuration data: \" + e.getMessage());\n\t\t}\n\t\tcatch (final IOException e) {\n\t\t\tthrow new LSHException(\"Could open module data directory\");\n\t\t}\n\t\tcatch (final SAXException e) {\n\t\t\tthrow new LSHException(\"Unable to parse configuration template\");\n\t\t}\n\t\treturn config;\n\t}\n\n\t/**\n\t * Central location for building vector factory used by FunctionDatabase\n\t * @return the LSHVectorFactory object\n\t */\n\tpublic static WeightedLSHCosineVectorFactory generateLSHVectorFactory() {\n\t\treturn new WeightedLSHCosineVectorFactory();\n\t}\n\n\t/**\n\t * Get the maximum number of functions to be queried per staged query when searching\n\t * for similar functions.\n\t * @return maximum number of functions to be queried per staged query, or 0 for default\n\t * which is generally ten (10) per stage.  See {@link SFQueryInfo#DEFAULT_QUERIES_PER_STAGE}.\n\t */","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/FunctionDatabase.java#L300-L336","documentation":"Thrown by FunctionDatabase.loadConfigurationTemplate when the configuration template file exists but is not well-formed XML (SAXException). The template is parsed as XML to define signature weights and categories; a parse failure means the template is corrupt or malformed.","triggerScenarios":"config.loadTemplate encounters a SAXException while parsing the template file: unclosed tags, invalid characters, encoding mismatch, or structurally invalid XML.","commonSituations":"The template file was hand-edited and broken (unclosed tag, stray character). The file was transferred with a text mode that corrupted encoding/BOM. A partial write left a truncated XML file. A third-party or custom template does not conform to the expected schema.","solutions":["Validate the template file as well-formed XML using an XML linter or xmllint.","Restore the template from the original Ghidra distribution if it was edited or corrupted.","If using a custom template, ensure it matches the BSim configuration XML schema and all tags are properly closed.","Check for encoding issues (open and re-save as UTF-8 without BOM)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate the template is well-formed XML before passing to BSim (best-effort)\nResourceFile dir = Application.getModuleDataSubDirectory(\"\");\nResourceFile template = new ResourceFile(dir, configname);\ntry (InputStream in = template.getInputStream()) {\n    javax.xml.parsers.DocumentBuilderFactory.newInstance()\n        .newDocumentBuilder().parse(in); // throws if malformed\n} catch (Exception xmlEx) {\n    throw new IllegalArgumentException(\"Template is not well-formed XML: \" + xmlEx.getMessage());\n}\nConfiguration config = FunctionDatabase.loadConfigurationTemplate(configname);","typeGuard":null,"tryCatchPattern":"try {\n    Configuration config = FunctionDatabase.loadConfigurationTemplate(configname);\n} catch (LSHException e) {\n    if (e.getMessage().equals(\"Unable to parse configuration template\")) {\n        log.error(\"BSim config template '{}' is malformed XML\", configname, e);\n    }\n    throw e;\n}","preventionTips":["Never hand-edit template XML without validating it afterwards (xmllint or an XML linter).","Keep templates under version control so corruption is detectable.","Restore templates from the original distribution if parsing fails."],"tags":["bsim","configuration","xml-parsing","setup"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}