{"record":{"id":"7d18e0ef505f2a9a","repo":"NationalSecurityAgency/ghidra","slug":"extra-argument-key","errorCode":null,"errorMessage":"Extra argument '{key}'","messagePattern":"Extra argument '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/RemoteMethod.java","lineNumber":188,"sourceCode":"\t\t\t}\n\t\t\tObject arg = arguments.get(ent.getKey());\n\t\t\tif (arg instanceof TraceObject obj) {\n\t\t\t\tif (trace == null) {\n\t\t\t\t\ttrace = obj.getTrace();\n\t\t\t\t\tctx = trace.getObjectManager().getRootSchema().getContext();\n\t\t\t\t}\n\t\t\t\telse if (trace != obj.getTrace()) {\n\t\t\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\t\"All TraceObject parameters must come from the same trace\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tSchemaName schName = ent.getValue().type();\n\t\t\tTraceObjectSchema sch = ctx.getSchemaOrNull(schName);\n\t\t\tcheckType(ent.getKey(), schName, sch, arg);\n\t\t}\n\t\tfor (Map.Entry<String, Object> ent : arguments.entrySet()) {\n\t\t\tif (!parameters().containsKey(ent.getKey())) {\n\t\t\t\tthrow new IllegalArgumentException(\"Extra argument '\" + ent.getKey() + \"'\");\n\t\t\t}\n\t\t}\n\t\treturn trace;\n\t}\n\n\t/**\n\t * Invoke the remote method, getting a future result.\n\t * \n\t * <p>\n\t * This invokes the method asynchronously. The returned objects is a {@link CompletableFuture},\n\t * whose getters are overridden to prevent blocking the Swing thread for more than 1 second. Use\n\t * of this method is not recommended, if it can be avoided; however, you should not create a\n\t * thread whose sole purpose is to invoke this method. UI actions that need to invoke a remote\n\t * method should do so using this method, but they must be sure to handle errors using, e.g.,\n\t * using {@link CompletableFuture#exceptionally(Function)}, lest the actions fail silently.\n\t * \n\t * @param arguments the keyword arguments to the remote method\n\t * @return the future result","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-api/src/main/java/ghidra/debug/api/tracermi/RemoteMethod.java#L170-L206","documentation":"Thrown by RemoteMethod.validate() when the supplied argument map contains a key that is not among the method's declared parameters. After validating declared parameters, the method iterates over all supplied entries and rejects any unknown key.","triggerScenarios":"Calling validate(arguments) where arguments has a key not present in remoteMethod.parameters().","commonSituations":"Typos in argument keys; passing arguments meant for a different method version; stale keys left over after refactoring method signatures.","solutions":["Compare argument keys against method.parameters().keySet() and remove any unknown entries.","Derive the argument map keys directly from the declared parameters rather than hardcoding strings.","Log unknown keys at debug level before validate() to catch typos early."],"exampleFix":"// before\nmethod.validate(Map.of(\"target\", obj, \"trg\", obj2)); // 'trg' is a typo\n\n// after\nSet<String> allowed = method.parameters().keySet();\nargs.keySet().retainAll(allowed);\nmethod.validate(args);","handlingStrategy":"validation","validationCode":"// Remove unknown keys before validate:\nSet<String> allowed = method.parameters().keySet();\nSet<String> unknown = new HashSet<>(arguments.keySet());\nunknown.removeAll(allowed);\nif (!unknown.isEmpty()) {\n    throw new IllegalStateException(\"Unknown keys: \" + unknown);\n}","typeGuard":null,"tryCatchPattern":"try {\n    method.validate(arguments);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Extra argument\")) {\n        arguments.keySet().retainAll(method.parameters().keySet());\n    } else throw e;\n}","preventionTips":["Build argument maps from parameters().keySet() to avoid typos.","Log any unknown keys at debug level before invoking."],"tags":["tracermi","remote-method","argument-validation","debugger"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}