{"record":{"id":"e2fe54bb1338fb18","repo":"NationalSecurityAgency/ghidra","slug":"for-parameter-s-argument-s-is-not-a-s","errorCode":null,"errorMessage":"For parameter %s: argument %s is not a %s","messagePattern":"For parameter (.+?): argument (.+?) is not a (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/RemoteMethod.java","lineNumber":144,"sourceCode":"\t * @param sch the type of the parameter\n\t * @param arg the argument\n\t */\n\tstatic void checkType(String paramName, SchemaName schName, TraceObjectSchema sch,\n\t\t\tObject arg) {\n\t\t// if sch is null, it was definitely an object-type schema without context\n\t\tif (sch != null) {\n\t\t\tif (sch.getType() != TraceObject.class) {\n\t\t\t\tif (sch.getType().isInstance(arg)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (arg instanceof TraceObject obj) {\n\t\t\t\tif (sch.isAssignableFrom(obj.getSchema())) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow new IllegalArgumentException(\n\t\t\t\"For parameter %s: argument %s is not a %s\".formatted(paramName, arg, schName));\n\t}\n\n\t/**\n\t * Validate the given argument.\n\t * \n\t * <p>\n\t * This method is for checking parameter sanity before they are marshalled to the back-end. This\n\t * is called automatically during invocation. Clients can use this method to pre-test or\n\t * validate in the UI, when invocation is not yet desired.\n\t * \n\t * @param arguments the arguments\n\t * @return the trace if any object arguments were given, or null\n\t * @throws IllegalArgumentException if the arguments are not valid\n\t */\n\tdefault Trace validate(Map<String, Object> arguments) {\n\t\tTrace trace = null;\n\t\tSchemaContext ctx = PrimitiveTraceObjectSchema.MinimalSchemaContext.INSTANCE;","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/RemoteMethod.java#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nremoteMethod.invoke(Map.of(\"target\", someString));\n\n// after\nTraceObject obj = trace.getObjectManager().getObjectByPath(...);\nremoteMethod.invoke(Map.of(\"target\", obj));","handlingStrategy":"validation","validationCode":"// Before invoke/validate:\nSchemaContext ctx = PrimitiveTraceObjectSchema.MinimalSchemaContext.INSTANCE;\nfor (var ent : method.parameters().entrySet()) {\n    Object arg = arguments.get(ent.getKey());\n    if (arg == null) continue;\n    TraceObjectSchema sch = ctx.getSchemaOrNull(ent.getValue().type());\n    if (sch != null && sch.getType() != TraceObject.class\n            && !sch.getType().isInstance(arg)) {\n        throw new IllegalStateException(\"Bad type for \" + ent.getKey());\n    }\n    if (arg instanceof TraceObject obj && sch != null\n            && !sch.isAssignableFrom(obj.getSchema())) {\n        throw new IllegalStateException(\"Bad schema for \" + ent.getKey());\n    }\n}","typeGuard":"static boolean argMatchesType(Object arg, TraceObjectSchema sch) {\n    if (sch == null) return true;\n    if (sch.getType() != TraceObject.class)\n        return sch.getType().isInstance(arg);\n    return arg instanceof TraceObject o\n        && sch.isAssignableFrom(o.getSchema());\n}","tryCatchPattern":"try {\n    method.invoke(arguments);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"For parameter\")) {\n        // log and show the offending parameter/value to user\n    } else throw e;\n}","preventionTips":["Always fetch TraceObjects from the trace object manager rather than casting.","Confirm object schema matches the parameter's declared type before invoke."],"tags":["tracermi","remote-method","type-validation","trace-object","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}