{"record":{"id":"e1246d33d15ad09c","repo":"NationalSecurityAgency/ghidra","slug":"unexpected-argument-e1246d","errorCode":null,"errorMessage":"Unexpected argument: {}","messagePattern":"Unexpected argument: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java","lineNumber":324,"sourceCode":"\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\n\t\t\tif (optionName.startsWith(\"-\") && !optionName.startsWith(\"--\")) {\n\t\t\t\toption = SHORTCUT_OPTION_MAP.get(optionName); // map option to -- long form\n\t\t\t\tif (option == null) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Unsupported option use: \" + optionName);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!option.startsWith(\"--\")) {\n\t\t\t\tif (sawOptions) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"Unexpected argument: \" + option);\n\t\t\t\t}\n\t\t\t\tsubParams.add(params[i]);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tsawOptions = true;\n\t\t\tif (!GLOBAL_OPTIONS.contains(option) && !allowedParams.contains(option)) {\n\t\t\t\tthrow new IllegalArgumentException(\"Unsupported option use: \" + optionName);\n\t\t\t}\n\t\t\tif (!VALUE_OPTIONS.contains(option)) {\n\t\t\t\t// consume option without value arg as a boolean option\n\t\t\t\tif (value != null) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"Unsupported option specification: \" + optionName + \"=\");\n\t\t\t\t}\n\t\t\t\tbooleanOptions.add(option);\n\t\t\t}\n\t\t\telse if (!StringUtils.isBlank(value)) {","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java#L306-L342","documentation":"Thrown when a positional (non-option) argument appears after -- long-form options have already been encountered. BSim's argument parser tracks a sawOptions flag: once any -- option is seen, no further bare positional arguments are allowed. All positional arguments must come before all options.","triggerScenarios":"A command like 'bsim listexes h2://localhost/db --limit 10 extra_pos' where 'extra_pos' appears after --limit. The parser treats anything not starting with - as a positional argument and rejects it after options.","commonSituations":"Placing a file path or repository name after options instead of before them; accidentally including a stray token after the last option; shell glob expansion producing an unexpected token.","solutions":["Reorder arguments so all positional parameters precede all -- options.","Remove any stray or unexpected tokens from the command line.","Quote arguments that might be expanded by the shell to prevent unexpected tokens."],"exampleFix":"// before\nbsim delete h2://localhost/db --md5 abc123 /path/to/extra\n// error: Unexpected argument: /path/to/extra\n\n// after\nbsim delete h2://localhost/db /path/to/extra --md5 abc123","handlingStrategy":"validation","validationCode":"// Validate that no positional argument appears after the first -- option\nboolean sawOption = false;\nfor (String arg : args) {\n    if (arg.startsWith(\"--\")) {\n        sawOption = true;\n    } else if (!arg.startsWith(\"-\") && sawOption) {\n        throw new IllegalArgumentException(\"Positional argument '\" + arg + \"' appears after options\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always place positional arguments before any -- options on the command line.","Review the full command line for stray tokens before executing.","Quote shell-expanded arguments to prevent unexpected positional tokens."],"tags":["bsim","ghidra","command-line","argument-parsing","cli-usage"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}