{"record":{"id":"8f0fd47d1e39a2a1","repo":"NationalSecurityAgency/ghidra","slug":"unknown-command-8f0fd4","errorCode":null,"errorMessage":"Unknown command: {}","messagePattern":"Unknown command: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java","lineNumber":492,"sourceCode":"\t\t}\n\t\telse if (COMMAND_LIST_FUNCTIONS.equals(command)) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n\t\t\tdoListFunctions(subParams);\n\t\t}\n\t\telse if (COMMAND_LIST_EXES.equals(command)) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n\t\t\tdoListExes(subParams);\n\t\t}\n\t\telse if (COMMAND_GET_EXE_COUNT.equals(command)) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n\t\t\tdoGetCount(subParams);\n\t\t}\n\t\telse if (COMMAND_DUMP_SIGS.equals(command)) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n\t\t\tdoDumpSigs(subParams);\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalArgumentException(\"Unknown command: \" + command);\n\t\t}\n\t}\n\n\tprivate void processSigAndUpdateOptions(String urlstring)\n\t\t\tthrows IllegalArgumentException, MalformedURLException, URISyntaxException {\n\t\tString bsimURLOption = optionValueMap.get(BSIM_URL_OPTION);\n\t\tString configOption = optionValueMap.get(CONFIG_OPTION);\n\t\tif (configOption != null) {\n\t\t\tif (bsimURLOption != null) {\n\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\tBSIM_URL_OPTION + \" and \" + CONFIG_OPTION + \" options may not both be present\");\n\t\t\t}\n\t\t\tsetupGhidraURL(urlstring);\n\t\t}\n\t\telse if (bsimURLOption != null) {\n\t\t\tsetupURLs(urlstring, bsimURLOption);\n\t\t}\n\t\telse {","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java#L474-L510","documentation":"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().","triggerScenarios":"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.","commonSituations":"Contributing a new BSim subcommand; the code compiles and passes argument-parsing tests but fails when the command is actually dispatched for execution.","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()."],"exampleFix":"// before: command registered and in ALLOWED_OPTION_MAP, but no dispatch branch\nelse if (COMMAND_DUMP_SIGS.equals(command)) {\n    bsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n    doDumpSigs(subParams);\n}\nelse {\n    throw new IllegalArgumentException(\"Unknown command: \" + command); // hits here!\n}\n\n// after: add the missing branch\nelse if (COMMAND_DUMP_SIGS.equals(command)) {\n    bsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n    doDumpSigs(subParams);\n}\nelse if (COMMAND_NEW_CMD.equals(command)) {\n    bsimURL = BSimClientFactory.deriveBSimURL(urlstring);\n    doNewCmd(subParams);\n}\nelse {\n    throw new IllegalArgumentException(\"Unknown command: \" + command);","handlingStrategy":"validation","validationCode":"// In a test: verify every command in COMMAND_SET has a dispatch path\nSet<String> dispatched = Set.of(\"createdatabase\",\"dropdatabase\", ... );\nassert COMMAND_SET.equals(dispatched) : \"Missing dispatch for: \" + Sets.difference(COMMAND_SET, dispatched);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["bsim","ghidra","command-line","programming-bug","internal"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}