apache/shenyu · error · ShenyuException
args.length < types.length
Error message
args.length < types.length
What it means
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.
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.
Example fix
// before
Object result = method.invoke(service, new Object[]{arg1}); // 1 arg, 2 types
// after
ParamCheckUtils.checkParamsLength(2, method.getParameterTypes().length);
Object result = method.invoke(service, arg1, arg2); Defensive patterns
Strategy: validation
Validate before calling
ParamCheckUtils.checkParamsLength(args.length, method.getParameterTypes().length);
Type guard
boolean argsMatch = args != null && types != null && args.length >= types.length;
Try / catch
try { invoke(...); } catch (ShenyuException e) { if (e.getMessage().contains("args.length")) { respond 400 "missing arguments"; } } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- the validation ExistProviderMethod invoked error
- Max response body size must not be negative
- build json response message is error, newBuilder method is…
- can not get defaultInstance Field of
- can not get fullMethodName Field of
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/94a6321d587c8146.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-common/src/main/java/org/apache/shenyu/common/utils/ParamCheckUtils.java:47
/**
* Body is empty boolean.
*
* @param body the body
* @return the boolean
*/
public static boolean bodyIsEmpty(final String body) {
return Objects.isNull(body) || StringUtils.isEmpty(body) || "null".equals(body);
}
/**
* Check params length.
* @param argsLength params length.
* @param typesLength types length.
*/
public static void checkParamsLength(final Integer argsLength, final Integer typesLength) {
if (argsLength < typesLength) {
throw new ShenyuException("args.length < types.length");
}
}
}
View on GitHub (pinned to 567142e072)