NationalSecurityAgency/ghidra · error · LSHException
Unknown query tag: {mainName}
Error message
Unknown query tag: {mainName} What it means
Thrown by BSimQuery.restoreXml (the static factory method) when the root XML element name does not match any known BSim query type. The method recognizes 16 query tags (querynearest, querynearestvector, insert, queryinfo, update, queryname, delete, createdatabase, querychildren, querycluster, querypair, installcategory, installmetadata, installtag, adjustindex, passwordchange, prewarmrequest). Any other root tag triggers this exception.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/protocol/BSimQuery.java:154
query = new InstallCategoryRequest();
}
else if (mainName.equals("installmetadata")) {
query = new InstallMetadataRequest();
}
else if (mainName.equals("installtag")) {
query = new InstallTagRequest();
}
else if (mainName.equals("adjustindex")) {
query = new AdjustVectorIndex();
}
else if (mainName.equals("passwordchange")) {
query = new PasswordChange();
}
else if (mainName.equals("prewarmrequest")) {
query = new PrewarmRequest();
}
else {
throw new LSHException("Unknown query tag: "+mainName);
}
query.restoreXml(parser,vectorFactory);
return query;
}
}
View on GitHub (pinned to d5f144c24d)
Solutions
- Verify the XML root element matches one of the 16 recognized query tags (querynearest, insert, queryinfo, etc.).
- Ensure the Ghidra/BSim version that generated the XML matches or is compatible with the version parsing it.
- Print the root element name (parser.peek().getName()) before restoreXml to debug.
- If you have a custom query type, extend BSimQuery and register it in the factory.
Example fix
// before
else {
throw new LSHException("Unknown query tag: "+mainName);
}
// after — list valid tags in the error
else {
throw new LSHException("Unknown query tag: '" + mainName + "'. " +
"Valid tags: querynearest, querynearestvector, insert, queryinfo, " +
"update, queryname, delete, createdatabase, querychildren, querycluster, " +
"querypair, installcategory, installmetadata, installtag, adjustindex, " +
"passwordchange, prewarmrequest");
} Defensive patterns
Strategy: validation
Validate before calling
// Validate the XML root element before calling restoreXml
Set<String> validTags = Set.of("querynearest", "querynearestvector", "insert",
"queryinfo", "update", "queryname", "delete", "createdatabase",
"querychildren", "querycluster", "querypair", "installcategory",
"installmetadata", "installtag", "adjustindex", "passwordchange",
"prewarmrequest");
String rootName = parser.peek().getName();
if (!validTags.contains(rootName)) {
throw new IllegalArgumentException(
"Root element '" + rootName + "' is not a recognized BSim query tag. " +
"Valid tags: " + validTags);
} Type guard
public static final Set<String> VALID_BSIM_QUERY_TAGS = Set.of(
"querynearest", "querynearestvector", "insert", "queryinfo", "update",
"queryname", "delete", "createdatabase", "querychildren", "querycluster",
"querypair", "installcategory", "installmetadata", "installtag",
"adjustindex", "passwordchange", "prewarmrequest");
public static boolean isValidQueryRootTag(String tagName) {
return VALID_BSIM_QUERY_TAGS.contains(tagName);
} Try / catch
try {
BSimQuery<?> query = BSimQuery.restoreXml(parser, vectorFactory);
} catch (LSHException e) {
if (e.getMessage().startsWith("Unknown query tag")) {
// Version mismatch or wrong file — check the tag name
String tag = parser.peek().getName();
throw new IllegalArgumentException(
"Unrecognized BSim query tag '" + tag + "'. " +
"Ensure sender and receiver use compatible Ghidra versions.", e);
}
throw e;
} Prevention
- Ensure the Ghidra/BSim version parsing the XML matches or is compatible with the version that generated it.
- Validate the XML root element name against the known tag set before calling restoreXml.
- Log the root tag name when parsing fails for quick diagnosis.
- Do not pass arbitrary XML files to BSimQuery.restoreXml — verify the source first.
When it happens
Trigger: Parsing an XML document whose root element is not one of the recognized BSim query tags. This happens when feeding a non-BSim XML file, a BSim protocol message from a newer/older version that uses an unrecognized tag, or a malformed hand-crafted XML. The method peeks the root element name and tries to match it against the known set.
Common situations: Version mismatch: the XML was generated by a newer Ghidra/BSim version that introduced a new query type not recognized by the running version; a user or tool constructed an XML file with a typo in the root tag; the XML file is not a BSim query at all (wrong file passed); the parser was pointed at the wrong file.
Related errors
- Protocol error: Invalid value kinds
- Protocol not permissable for BSim URL
- Unsupported protocol: {}
- Query signature data has no setting information
- Query signature data does not match database
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/0d1e7fab181f4a35.
Report an issue: GitHub.