NationalSecurityAgency/ghidra · error · IllegalArgumentException
Unexpected argument: {}
Error message
Unexpected argument: {} What it means
Thrown when, after shortcut resolution, the resolved `option` token does not start with '--'. This catches bare positional values or stray tokens that appear in the options portion of the command line where an option flag is expected.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:276
// although not prefered, allow option value to be specified as --option=value
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("--")) {
throw new IllegalArgumentException("Unexpected argument: " + option);
}
if (!GLOBAL_OPTIONS.contains(option) && !allowedParams.contains(option)) {
throw new IllegalArgumentException("Unsupported option use: " + optionName);
}
if (!VALUE_OPTIONS.contains(option)) {
// option without value arg
if (value != null) {
throw new IllegalArgumentException(
"Unsupported option specification: " + optionName + "=");
}
}
else if (StringUtils.isBlank(value)) {
// consume next param as option value
if (++i == params.length) {
throw new IllegalArgumentException("Missing option value: " + optionName);
}View on GitHub (pinned to d5f144c24d)
Solutions
- Prefix the value with its intended option flag, e.g. `--port 5432`.
- Re-check argument ordering: required positional parameters come first, then options.
- Confirm no stray tokens leaked in from shell expansion.
Example fix
// before bsim control configure myhost 5432 // after bsim control configure myhost --port 5432
Defensive patterns
Strategy: validation
Validate before calling
// Reject bare tokens that look like values, not options, in the options region.
for (String t : optionTokens) {
if (!t.startsWith("-")) {
System.err.println("Unexpected non-option argument: " + t + ". Did you omit a --flag?");
return;
}
} Try / catch
try {
launchable.readOptions(command, params, discard);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unexpected argument:")) {
System.err.println("An option flag may be missing before: " + e.getMessage());
}
throw e;
} Prevention
- Always pair a value with its --flag; never pass a bare value in the options region.
- Validate that option-region tokens are dash-prefixed before invoking the parser.
- Keep positionals and options in the order the tool expects.
When it happens
Trigger: A token that does not start with '-' at all (a raw value) reaches the option loop, so `option` stays as the bare token and fails the `option.startsWith("--")` check at line 276.
Common situations: Forgetting the option flag before a value (e.g. a port number with no `--port`), placing positional arguments in the wrong slot, or a value whose preceding flag was dropped.
Related errors
- Unknown command: {}
- Unsupported command: {}
- Unsupported option use: {}
- Unsupported option specification: {}=
- Missing option value: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/67eab435f5ba854d.
Report an issue: GitHub.