NationalSecurityAgency/ghidra · warning · IllegalArgumentException
Unexpected argument: {}
Error message
Unexpected argument: {} What it means
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.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/ingest/BSimLaunchable.java:324
int ix = optionName.indexOf("=");
if (ix > 1) {
value = optionName.substring(ix + 1);
optionName = optionName.substring(0, ix);
}
}
String option = optionName;
if (optionName.startsWith("-") && !optionName.startsWith("--")) {
option = SHORTCUT_OPTION_MAP.get(optionName); // map option to -- long form
if (option == null) {
throw new IllegalArgumentException("Unsupported option use: " + optionName);
}
}
if (!option.startsWith("--")) {
if (sawOptions) {
throw new IllegalArgumentException("Unexpected argument: " + option);
}
subParams.add(params[i]);
continue;
}
sawOptions = true;
if (!GLOBAL_OPTIONS.contains(option) && !allowedParams.contains(option)) {
throw new IllegalArgumentException("Unsupported option use: " + optionName);
}
if (!VALUE_OPTIONS.contains(option)) {
// consume option without value arg as a boolean option
if (value != null) {
throw new IllegalArgumentException(
"Unsupported option specification: " + optionName + "=");
}
booleanOptions.add(option);
}
else if (!StringUtils.isBlank(value)) {View on GitHub (pinned to d5f144c24d)
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.
Example fix
// before bsim delete h2://localhost/db --md5 abc123 /path/to/extra // error: Unexpected argument: /path/to/extra // after bsim delete h2://localhost/db /path/to/extra --md5 abc123
Defensive patterns
Strategy: validation
Validate before calling
// Validate that no positional argument appears after the first -- option
boolean sawOption = false;
for (String arg : args) {
if (arg.startsWith("--")) {
sawOption = true;
} else if (!arg.startsWith("-") && sawOption) {
throw new IllegalArgumentException("Positional argument '" + arg + "' appears after options");
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unsupported option use: {}
- Unsupported option specification: {}=
- Missing option value: {}
- Missing required parameter: {}
- Missing required parameter ({}) before specified option: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/e1246d33d15ad09c.
Report an issue: GitHub.