NationalSecurityAgency/ghidra · error · IllegalArgumentException
For parameter : argument is not a
Error message
For parameter %s: argument %s is not a %s
What it means
Thrown by RemoteMethod.checkType() when a supplied argument fails type validation against the declared parameter schema. Validation considers both Java type compatibility (sch.getType().isInstance(arg)) and, for TraceObject arguments, schema assignability against the target object schema.
Solutions
- Inspect the parameter's declared type via RemoteParameter.type() and ensure the argument matches.
- For TraceObject arguments, verify obj.getSchema() is assignable to the parameter schema using sch.isAssignableFrom(obj.getSchema()).
- Fetch the correct object from the trace's object manager before passing it.
Example fix
// before
remoteMethod.invoke(Map.of("target", someString));
// after
TraceObject obj = trace.getObjectManager().getObjectByPath(...);
remoteMethod.invoke(Map.of("target", obj)); Defensive patterns
Strategy: validation
Validate before calling
// Before invoke/validate:
SchemaContext ctx = PrimitiveTraceObjectSchema.MinimalSchemaContext.INSTANCE;
for (var ent : method.parameters().entrySet()) {
Object arg = arguments.get(ent.getKey());
if (arg == null) continue;
TraceObjectSchema sch = ctx.getSchemaOrNull(ent.getValue().type());
if (sch != null && sch.getType() != TraceObject.class
&& !sch.getType().isInstance(arg)) {
throw new IllegalStateException("Bad type for " + ent.getKey());
}
if (arg instanceof TraceObject obj && sch != null
&& !sch.isAssignableFrom(obj.getSchema())) {
throw new IllegalStateException("Bad schema for " + ent.getKey());
}
} Type guard
static boolean argMatchesType(Object arg, TraceObjectSchema sch) {
if (sch == null) return true;
if (sch.getType() != TraceObject.class)
return sch.getType().isInstance(arg);
return arg instanceof TraceObject o
&& sch.isAssignableFrom(o.getSchema());
} Try / catch
try {
method.invoke(arguments);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("For parameter")) {
// log and show the offending parameter/value to user
} else throw e;
} Prevention
- Always fetch TraceObjects from the trace object manager rather than casting.
- Confirm object schema matches the parameter's declared type before invoke.
When it happens
Trigger: Calling RemoteMethod.validate(arguments) or invoking a remote method with an argument whose Java type does not match the parameter schema, or passing a TraceObject whose object schema is not assignable to the parameter's declared schema.
Common situations: Passing a String where a TraceObject is expected; passing a TraceObject of schema 'Process' where 'Thread' is required; mismatched object schemas from different traces or wrong element types.
Related errors
- All TraceObject parameters must come from the same trace
- Extra argument
- Missing required parameter
- Missing required parameter
- The given program is dynamic, i.e., a trace view
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/e2fe54bb1338fb18.
Report an issue: GitHub.
Appendix: source
Thrown at Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/RemoteMethod.java:144
* @param sch the type of the parameter
* @param arg the argument
*/
static void checkType(String paramName, SchemaName schName, TraceObjectSchema sch,
Object arg) {
// if sch is null, it was definitely an object-type schema without context
if (sch != null) {
if (sch.getType() != TraceObject.class) {
if (sch.getType().isInstance(arg)) {
return;
}
}
else if (arg instanceof TraceObject obj) {
if (sch.isAssignableFrom(obj.getSchema())) {
return;
}
}
}
throw new IllegalArgumentException(
"For parameter %s: argument %s is not a %s".formatted(paramName, arg, schName));
}
/**
* Validate the given argument.
*
* <p>
* This method is for checking parameter sanity before they are marshalled to the back-end. This
* is called automatically during invocation. Clients can use this method to pre-test or
* validate in the UI, when invocation is not yet desired.
*
* @param arguments the arguments
* @return the trace if any object arguments were given, or null
* @throws IllegalArgumentException if the arguments are not valid
*/
default Trace validate(Map<String, Object> arguments) {
Trace trace = null;
SchemaContext ctx = PrimitiveTraceObjectSchema.MinimalSchemaContext.INSTANCE;View on GitHub (pinned to d5f144c24d)