NationalSecurityAgency/ghidra · error · IllegalArgumentException

Missing username

Error message

Missing username

What it means

Thrown by scanUsername(params, slot) when the positional username argument is missing for adduser/dropuser/changeprivilege/resetpassword commands. These commands operate on a specific database role, so the name is mandatory.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/BSimControlLaunchable.java:966

			throw new IllegalArgumentException("Missing data directory");
		}
		dataDirectory = new File(params[slot]);
		if (!dataDirectory.isDirectory()) {
			throw new IllegalArgumentException(
				"Data directory " + dataDirectory.getAbsolutePath() + " does not exist");
		}
		dataDirectory = dataDirectory.getCanonicalFile();
	}

	/**
	 * Scan the username from the command-line
	 * @param params are the command-line arguments
	 * @param slot is the position to retrieve the username argument
	 * @throws IllegalArgumentException if the user name is not in the given params
	 */
	private void scanUsername(String[] params, int slot) throws IllegalArgumentException {
		if (params.length <= slot) {
			throw new IllegalArgumentException("Missing username");
		}
		specifiedUserName = params[slot];
	}

	/**
	 * Scan command-line for a particular privilege level. Administrator privileges are
	 * requested with the exact String "admin", anything is a request for a read-only user 
	 * @param params are the command-line arguments
	 * @param slot is the position to retrieve the user name argument
	 * @throws IllegalArgumentException the privilege parameter is missing
	 */
	private void scanPrivilege(String[] params, int slot) throws IllegalArgumentException {
		if (params.length <= slot) {
			throw new IllegalArgumentException("Missing desired privilege (admin or user)");
		}
		if (params[slot].equals("admin")) {
			adminPrivilegeRequested = true;
		}

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Provide the username as the trailing positional argument, e.g. `bsim_ctl adduser [opts] <username>`.
  2. Re-check argument ordering against the command usage.
  3. For PKI adduser, also supply `--dn "CN=..."`.

Example fix

// before
bsim_ctl adduser
// after
bsim_ctl adduser alice
Defensive patterns

Strategy: validation

Validate before calling

if (args.length <= usernameSlot) {
    throw new IllegalArgumentException("Missing <username> argument for " + command);
}

Type guard

public boolean hasUsernameArg(String[] args, int slot) {
    return args != null && args.length > slot && StringUtils.isNotBlank(args[slot]);
}

Try / catch

try {
    bsimControl.exec(args);
} catch (IllegalArgumentException e) {
    if ("Missing username".equals(e.getMessage())) {
        usage();
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Running `bsim_ctl adduser [options]` without the trailing username argument, i.e. params.length <= slot.

Common situations: Forgot the username positional; option value consumed the slot unexpectedly; copy-paste from a partial example.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/233e1f15aa0209ed. Report an issue: GitHub.