{"record":{"id":"17857181ec067f98","repo":"apache/dubbo","slug":"dubbomethodarg-index-parameters-length","errorCode":null,"errorMessage":"DubboMethodArg index >= parameters.length","messagePattern":"DubboMethodArg index >= parameters\\.length","errorType":"exception","errorClass":"IndexOutOfBoundsException","httpStatus":null,"severity":"error","filePath":"dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java","lineNumber":123,"sourceCode":"            for (int index = 0; index < argp.size(); index++) {\n                boolean match = argp.get(index).isMatch(parameterTypes[index].getName())\n                        || argp.get(index).isMatch(parameterTypes[index].getSimpleName());\n                if (!match) {\n                    return false;\n                }\n            }\n        }\n\n        List<DubboMethodArg> args = getArgs();\n        if (args != null && args.size() > 0) {\n            if (arguments == null || arguments.length == 0) {\n                return false;\n            }\n\n            for (DubboMethodArg dubboMethodArg : args) {\n                int index = dubboMethodArg.getIndex();\n                if (index >= arguments.length) {\n                    throw new IndexOutOfBoundsException(\"DubboMethodArg index >= parameters.length\");\n                }\n                if (!dubboMethodArg.isMatch(arguments[index])) {\n                    return false;\n                }\n            }\n        }\n\n        return true;\n    }\n}\n","sourceCodeStart":105,"sourceCodeEnd":134,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/rule/virtualservice/match/DubboMethodMatch.java#L105-L134","documentation":"Thrown by DubboMethodMatch.isMatch() (IndexOutOfBoundsException) when a DubboMethodArg in a mesh/virtual-service route match specifies an argument index greater than or equal to the actual number of arguments in the live invocation. The match config references an argument position that the call does not have.","triggerScenarios":"A Dubbo virtual-service (mesh) route rule defines method arg matching with args[].index >= the runtime argument count of the invoked method. isMatch loops the configured args and checks each index against arguments.length; an out-of-range index aborts with this message.","commonSituations":"Method overloading where the rule was written for a method with more parameters; a stale route rule after a method signature changed (params removed); a rule that assumes 0-based indexing differently than the actual call.","solutions":["Align the route rule's arg indexes with the actual method signature: each args[].index must be < the method's parameter count.","After changing a service method signature, update or remove mesh route rules that reference argument indexes.","If the rule should simply not match methods with fewer args, prefer the 'argc' matcher to filter by argument count instead of indexing."],"exampleFix":"# before (broken): rule indexes arg 2 but method has 2 params (index 0,1)\napiType: dubbo\ndubbo:\n  - services: [{name: FooService}]\n    routedBy: [vs1]\n  - methods:\n      - nameMatch: {mode: exact, value: doStuff}\n        args:\n          - {index: 2, type: string, strMatch: {mode: exact, value: x}}\n\n# after\n        args:\n          - {index: 1, type: string, strMatch: {mode: exact, value: x}}","handlingStrategy":"validation","validationCode":"// Validate route rule arg indexes against the method signature before registering\nfor (DubboMethodArg arg : match.getArgs()) {\n    if (arg.getIndex() >= method.getParameterCount()) {\n        throw new IllegalArgumentException(\n            \"Route rule arg index \" + arg.getIndex() + \" out of range for \"\n                + method.getName() + \" (\" + method.getParameterCount() + \" params)\");\n    }\n}","typeGuard":null,"tryCatchPattern":"// The throw happens during routing; catch at the invocation boundary\ntry {\n    return invoker.invoke(inv);\n} catch (IndexOutOfBoundsException e) {\n    if (e.getMessage().contains(\"DubboMethodArg index\")) {\n        log.error(\"Stale mesh route rule references out-of-range arg; routing degraded\", e);\n        // fall back: retry without the offending route or alert ops\n    }\n    throw e;\n}","preventionTips":["Keep mesh route arg indexes in sync with the service method signature.","When a method's parameters change, review and update route rules that index args.","Prefer the argc matcher over arg indexing when the rule only needs argument-count filtering."],"tags":["router","mesh","virtual-service","validation","config"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}