apache/skywalking · error · IllegalArgumentException
MAL extension {}::{} expects {} argument(s), got {}
Error message
MAL extension {}::{} expects {} argument(s), got {} What it means
Thrown by MALMethodChainCodegen when a namespace::method() extension call passes a number of MAL arguments that does not match the Java method's parameter count minus the implicit SampleFamily first parameter (expectedArgs = em.getExtraParamTypes().length). The compiler needs an exact arity match to emit a direct static call, so mismatched counts abort compilation.
Source
Thrown at oap-server/analyzer/meter-analyzer/src/main/java/org/apache/skywalking/oap/meter/analyzer/v2/compiler/MALMethodChainCodegen.java:157
*
* <p>For {@code .test::scale(3.0)} on variable {@code _metric}, generates:
* {@code _metric = TestMalExtension.scale(_metric, 3.0);}
*/
private void emitExtensionCall(final StringBuilder sb,
final String var,
final MALExpressionModel.MethodCall mc) {
final String ns = mc.getNamespace();
final String method = mc.getName();
final MalExtensionRegistry.ExtensionMethod em =
MalExtensionRegistry.lookup(ns, method);
if (em == null) {
throw new IllegalArgumentException(
"Unknown MAL extension function: " + ns + "::" + method);
}
final List<MALExpressionModel.Argument> args = mc.getArguments();
final int expectedArgs = em.getExtraParamTypes().length;
if (args.size() != expectedArgs) {
throw new IllegalArgumentException(
"MAL extension " + ns + "::" + method + " expects "
+ expectedArgs + " argument(s), got " + args.size());
}
sb.append(" ").append(var).append(" = ")
.append(em.getDeclaringClass()).append('.')
.append(em.getMethodName()).append('(')
.append(var);
for (int i = 0; i < args.size(); i++) {
sb.append(", ");
generateExtensionArg(sb, args.get(i), em.getExtraParamTypes()[i]);
}
sb.append(");\n");
}
/**
* Generates a typed argument for an extension function call.
* Emits raw literals: {@code 3.0}, {@code 10L}, {@code 3.0F}, {@code 10}.
*/View on GitHub (pinned to 102af09b4a)
Solutions
- Count the arguments in the MAL call and make them equal to the Java method's parameters after the SampleFamily one
- If the extension method changed, update the rule YAML to pass the new argument
- Provide overloaded @MALContextFunction methods with distinct arities only if they have different Java names (same-name duplicates are rejected by the registry)
Example fix
// extension
@MALContextFunction
public static SampleFamily filterTag(SampleFamily sf, String key, String value) { ... }
# before
expr: m.sum([]).myext::filterTag("env")
# after
expr: m.sum([]).myext::filterTag("env", "prod") Defensive patterns
Strategy: validation
Validate before calling
MalExtensionRegistry.ExtensionMethod em = MalExtensionRegistry.lookup(ns, method);
if (em != null && callArgs.size() != em.getExtraParamTypes().length) {
throw new IllegalArgumentException(ns + "::" + method + " expects "
+ em.getExtraParamTypes().length + " args, got " + callArgs.size());
} Try / catch
catch IllegalArgumentException at rule compile; report expected vs actual arity to the rule author
Prevention
- Keep a table of extension signatures next to the rule templates
- When changing an extension method's parameters, grep all rule YAMLs for the ns::method call sites
When it happens
Trigger: Extension 'public static SampleFamily filterTag(SampleFamily sf, String key, String value)' invoked as '.myext::filterTag("env")' (1 arg, expects 2), or a zero-extra-param method called with arguments '.myext::noop(1.0)'.
Common situations: Extending an extension method signature in a new jar version (added parameter) while rules still use the old call shape; copy-pasting an example rule that targets a different version of the extension.
Related errors
- Unknown MAL extension function: {}::{}
- Expected String argument for extension function, got {}
- Expected number argument for extension function, got {}
- Load meter analyzer configs failed
- {slot} value '{numText}' exceeds the supported range (must f
AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14).
Data as JSON: /api/errors/ae47443346479ade.
Report an issue: GitHub.