NationalSecurityAgency/ghidra · error · IllegalArgumentException
Unknown command: {}
Error message
Unknown command: {} What it means
Thrown from the terminal else branch of the command dispatch if-else chain in run() (line 491). Because COMMAND_SET.contains(command) already validated the command at line 399, and all 18 commands have dispatch branches (lines 412-489), this is a defensive guard indicating a programming bug: a new command was registered via defineCommand() (and added to COMMAND_SET) but no corresponding dispatch branch was added in run().
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java:492
}
else if (COMMAND_LIST_FUNCTIONS.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doListFunctions(subParams);
}
else if (COMMAND_LIST_EXES.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doListExes(subParams);
}
else if (COMMAND_GET_EXE_COUNT.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doGetCount(subParams);
}
else if (COMMAND_DUMP_SIGS.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doDumpSigs(subParams);
}
else {
throw new IllegalArgumentException("Unknown command: " + command);
}
}
private void processSigAndUpdateOptions(String urlstring)
throws IllegalArgumentException, MalformedURLException, URISyntaxException {
String bsimURLOption = optionValueMap.get(BSIM_URL_OPTION);
String configOption = optionValueMap.get(CONFIG_OPTION);
if (configOption != null) {
if (bsimURLOption != null) {
throw new IllegalArgumentException(
BSIM_URL_OPTION + " and " + CONFIG_OPTION + " options may not both be present");
}
setupGhidraURL(urlstring);
}
else if (bsimURLOption != null) {
setupURLs(urlstring, bsimURLOption);
}
else {View on GitHub (pinned to d5f144c24d)
Solutions
- Add an else-if branch for the new command in the dispatch chain of run() (around lines 412-489).
- Ensure the branch calls the appropriate do* method and sets up bsimURL/ghidraURL as needed.
- Add an integration test that runs the new command end-to-end through BSimLaunchable.run().
Example fix
// before: command registered and in ALLOWED_OPTION_MAP, but no dispatch branch
else if (COMMAND_DUMP_SIGS.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doDumpSigs(subParams);
}
else {
throw new IllegalArgumentException("Unknown command: " + command); // hits here!
}
// after: add the missing branch
else if (COMMAND_DUMP_SIGS.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doDumpSigs(subParams);
}
else if (COMMAND_NEW_CMD.equals(command)) {
bsimURL = BSimClientFactory.deriveBSimURL(urlstring);
doNewCmd(subParams);
}
else {
throw new IllegalArgumentException("Unknown command: " + command); Defensive patterns
Strategy: validation
Validate before calling
// In a test: verify every command in COMMAND_SET has a dispatch path
Set<String> dispatched = Set.of("createdatabase","dropdatabase", ... );
assert COMMAND_SET.equals(dispatched) : "Missing dispatch for: " + Sets.difference(COMMAND_SET, dispatched); Prevention
- When adding a new command, add a dispatch branch (else-if) in run() alongside the COMMAND_SET and ALLOWED_OPTION_MAP entries.
- Write a test that iterates COMMAND_SET and asserts each command reaches its do* method.
- Consider replacing the if-else chain with a command-dispatch map to make missing entries a compile-time issue.
When it happens
Trigger: A developer adds a new command via defineCommand() and adds it to ALLOWED_OPTION_MAP, but forgets to add an else-if branch in the dispatch chain of run(). The command passes all validation checks but falls through to the else.
Common situations: Contributing a new BSim subcommand; the code compiles and passes argument-parsing tests but fails when the command is actually dispatched for execution.
Related errors
- Unsupported command: {}
- URL is not ghidra protocol: {}
- Invalid repository URL: {}
- Unable to infer ghidra URL from BSim file DB URL
- Unsupported option use: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/8f0fd47d1e39a2a1.
Report an issue: GitHub.