{"record":{"id":"94a6321d587c8146","repo":"apache/shenyu","slug":"args-length-types-length","errorCode":null,"errorMessage":"args.length < types.length","messagePattern":"args\\.length < types\\.length","errorType":"validation","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-common/src/main/java/org/apache/shenyu/common/utils/ParamCheckUtils.java","lineNumber":47,"sourceCode":"    \n    /**\n     * Body is empty boolean.\n     *\n     * @param body the body\n     * @return the boolean\n     */\n    public static boolean bodyIsEmpty(final String body) {\n        return Objects.isNull(body) || StringUtils.isEmpty(body) || \"null\".equals(body);\n    }\n\n    /**\n     * Check params length.\n     * @param argsLength params length.\n     * @param typesLength types length.\n     */\n    public static void checkParamsLength(final Integer argsLength, final Integer typesLength) {\n        if (argsLength < typesLength) {\n            throw new ShenyuException(\"args.length < types.length\");\n        }\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-common/src/main/java/org/apache/shenyu/common/utils/ParamCheckUtils.java#L29-L51","documentation":"ParamCheckUtils.checkParamsLength enforces that the number of supplied arguments matches the expected number of parameter types. If argsLength is less than typesLength it throws ShenyuException 'args.length < types.length', preventing ArrayIndexOutOfBoundsException later when mapping args to types.","triggerScenarios":"Invoking reflection-based calls (e.g. in proxy plugins) with fewer actual arguments than declared parameter types; passing null/empty args array to a method with required parameters.","commonSituations":"Client metadata (parameterTypes vs args) out of sync after backend API signature change; generic invocations (Dubbo/HTTP proxy) built from MetaData with truncated args; request body missing fields.","solutions":["Ensure the caller supplies one argument per declared parameter type before invoking.","Validate request payloads on the client side so all required args are present.","Check that MetaData parameterTypes and args registered by the backend service are consistent (re-register the service after signature changes).","Wrap calls with checkParamsLength defensively and surface a clear client error."],"exampleFix":"// before\nObject result = method.invoke(service, new Object[]{arg1}); // 1 arg, 2 types\n// after\nParamCheckUtils.checkParamsLength(2, method.getParameterTypes().length);\nObject result = method.invoke(service, arg1, arg2);","handlingStrategy":"validation","validationCode":"ParamCheckUtils.checkParamsLength(args.length, method.getParameterTypes().length);","typeGuard":"boolean argsMatch = args != null && types != null && args.length >= types.length;","tryCatchPattern":"try { invoke(...); } catch (ShenyuException e) { if (e.getMessage().contains(\"args.length\")) { respond 400 \"missing arguments\"; } }","preventionTips":["Match args count to parameterTypes before reflective invocation","Keep MetaData args/parameterTypes in sync with backend API signatures","Validate client payloads for all required fields","Re-register services after changing method signatures"],"tags":["reflection","argument-validation","rpc"],"backgroundTag":"missing-required-argument","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}