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

  1. Add an else-if branch for the new command in the dispatch chain of run() (around lines 412-489).
  2. Ensure the branch calls the appropriate do* method and sets up bsimURL/ghidraURL as needed.
  3. 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 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


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/8f0fd47d1e39a2a1. Report an issue: GitHub.