{"record":{"id":"343dab46bbb56702","repo":"NationalSecurityAgency/ghidra","slug":"unsupported-command-343dab","errorCode":null,"errorMessage":"Unsupported command: {}","messagePattern":"Unsupported command: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java","lineNumber":296,"sourceCode":"\t\telse if (ghidraURLString != null) {\n\t\t\tbsimURL = BSimClientFactory.deriveBSimURL(ghidraURLString);\n\t\t}\n\t}\n\n\t/**\n\t * Read in any optional parameters, strip them from the parameter stream\n\t * @param command command name\n\t * @param params is the original array of command line parameters\n\t * @param discard number of params already consumed\n\t * @return an array of parameters with optional ones stripped\n\t */\n\tprivate List<String> readOptions(String command, String[] params, int discard) {\n\n\t\tboolean sawOptions = false;\n\n\t\tSet<String> allowedParams = ALLOWED_OPTION_MAP.get(command);\n\t\tif (allowedParams == null) {\n\t\t\tthrow new IllegalArgumentException(\"Unsupported command: \" + command);\n\t\t}\n\n\t\tList<String> subParams = new ArrayList<String>();\n\t\tfor (int i = discard; i < params.length; ++i) {\n\t\t\tString optionName = params[i];\n\t\t\tString value = null;\n\n\t\t\tif (optionName.startsWith(\"-\")) {\n\t\t\t\t// although not prefered, allow option value to be specified as --option=value\n\t\t\t\tint ix = optionName.indexOf(\"=\");\n\t\t\t\tif (ix > 1) {\n\t\t\t\t\tvalue = optionName.substring(ix + 1);\n\t\t\t\t\toptionName = optionName.substring(0, ix);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tString option = optionName;\n","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java#L278-L314","documentation":"Thrown inside readOptions() when ALLOWED_OPTION_MAP.get(command) returns null. Because run() already validated the command against COMMAND_SET before calling readOptions(), and all 18 registered commands have entries in ALLOWED_OPTION_MAP, this is a defensive guard that indicates a programming bug: a developer registered a new command via defineCommand() but forgot to add its entry to ALLOWED_OPTION_MAP in the static initializer.","triggerScenarios":"A new BSim command is added to COMMAND_SET via defineCommand() but the developer omits the corresponding ALLOWED_OPTION_MAP.put(...) in the static block at lines 170-187. A user running that new command hits this before any work begins.","commonSituations":"Contributing a new BSim subcommand to Ghidra; the code compiles and passes unit tests that don't exercise the full CLI path, but the integration test or manual CLI run fails.","solutions":["Add the new command's option set to ALLOWED_OPTION_MAP in the static initializer block (around line 170).","Ensure defineCommand() and the ALLOWED_OPTION_MAP.put() call are both present for any new command.","Add an integration test that runs the command through BSimLaunchable.run() to catch the missing entry."],"exampleFix":"// before: command registered but not in ALLOWED_OPTION_MAP\nprivate static final String COMMAND_NEW_CMD = defineCommand(\"newcmd\");\n// ...\nstatic {\n    ALLOWED_OPTION_MAP.put(COMMAND_CREATE_DATABASE, CREATE_DATABASE_OPTIONS);\n    // COMMAND_NEW_CMD missing!\n}\n\n// after\nprivate static final Set<String> NEW_CMD_OPTIONS = Set.of(NAME_OPTION);\nstatic {\n    ALLOWED_OPTION_MAP.put(COMMAND_NEW_CMD, NEW_CMD_OPTIONS);","handlingStrategy":"validation","validationCode":"if (!ALLOWED_OPTION_MAP.containsKey(command)) {\n    throw new IllegalStateException(\n        \"Programming bug: command '\" + command + \"' is registered in COMMAND_SET \" +\n        \"but missing from ALLOWED_OPTION_MAP\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a new BSim command, always add it to both COMMAND_SET (via defineCommand) and ALLOWED_OPTION_MAP.","Write an integration test that runs each command through BSimLaunchable.run() to catch missing map entries.","Consider a unit test that iterates COMMAND_SET and asserts every entry exists in ALLOWED_OPTION_MAP."],"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"}