NationalSecurityAgency/ghidra · error · IllegalArgumentException

Type errors: {typeErrors}

Error message

Type errors: {typeErrors}

What it means

Thrown as IllegalArgumentException by LaunchParameter.validateArguments (LaunchParameter.java:66-80) when one or more argument values have a runtime type not assignable to the declared LaunchParameter type. Errors are accumulated into a LinkedHashMap (name -> 'val ... is not a ...') and reported together, so all type mismatches in one call are listed at once.

Source

Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/LaunchParameter.java:79

			Set<String> extraneous = new TreeSet<>(arguments.keySet());
			extraneous.removeAll(parameters.keySet());
			throw new IllegalArgumentException("Extraneous parameters: " + extraneous);
		}

		Map<String, String> typeErrors = null;
		for (Map.Entry<String, ValStr<?>> ent : arguments.entrySet()) {
			String name = ent.getKey();
			ValStr<?> val = ent.getValue();
			LaunchParameter<?> param = parameters.get(name);
			if (val.val() != null && !param.type.isAssignableFrom(val.val().getClass())) {
				if (typeErrors == null) {
					typeErrors = new LinkedHashMap<>();
				}
				typeErrors.put(name, "val '%s' is not a %s".formatted(val.val(), param.type()));
			}
		}
		if (typeErrors != null) {
			throw new IllegalArgumentException("Type errors: " + typeErrors);
		}
		return arguments;
	}

	public static Map<String, LaunchParameter<?>> mapOf(LaunchParameter<?>... parameters) {
		return mapOf(Arrays.asList(parameters));
	}

	public ValStr<T> decode(String string) {
		return decoder.decodeValStr(string);
	}

	public ValStr<T> get(Map<String, ValStr<?>> arguments) {
		if (arguments.containsKey(name)) {
			return ValStr.cast(type, arguments.get(name));
		}
		if (required) {
			throw new IllegalArgumentException(

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Convert each argument value to the declared parameter type before calling validateArguments.
  2. Inspect the declared param.type() for each failing name and align the value's class.
  3. For string-sourced input, decode using the parameter's own decoder (LaunchParameter.decode) which yields the correct ValStr type.

Example fix

// before
LaunchParameter<Integer> pPort = LaunchParameter.required("port", Integer.class, ...);
validateArguments(
  Map.of("port", pPort),
  Map.of("port", new ValStr<>("8080", null))); // String, not Integer -> Type error

// after
validateArguments(
  Map.of("port", pPort),
  Map.of("port", new ValStr<>(8080, null))); // Integer matches
Defensive patterns

Strategy: type-guard

Validate before calling

for (Map.Entry<String, ValStr<?>> e : arguments.entrySet()) {
    LaunchParameter<?> p = parameters.get(e.getKey());
    Object v = e.getValue().val();
    if (v != null && !p.type().isAssignableFrom(v.getClass())) {
        throw new IllegalArgumentException(e.getKey() + ": expected " + p.type());
    }
}

Type guard

boolean typesMatch(Map<String, LaunchParameter<?>> params, Map<String, ValStr<?>> args) {
    for (var e : args.entrySet()) {
        Object v = e.getValue().val();
        if (v == null) continue;
        if (!params.get(e.getKey()).type().isAssignableFrom(v.getClass())) return false;
    }
    return true;
}

Try / catch

try {
    LaunchParameter.validateArguments(parameters, arguments);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Type errors")) {
        for (var ent : arguments.entrySet()) {
            LaunchParameter<?> p = parameters.get(ent.getKey());
            ent.setValue(p.decode(String.valueOf(ent.getValue().val())));
        }
        LaunchParameter.validateArguments(parameters, arguments);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling validateArguments with a value whose class is not assignable to param.type: e.g. a String where an Integer is declared, a Long where a String is declared, or a custom object where a primitive wrapper is expected. val.val() must be non-null (null values skip the check).

Common situations: A launch.properties value parsed as the wrong type (string vs number); a UI field that returns text for a numeric parameter; a connector/launcher whose declared types changed; passing a boxed type the parameter does not accept.

Related errors


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