karatelabs/karate · error · RuntimeException
missing argument for param()
Error message
missing argument for param()
What it means
Generic arity guard inside HttpRequest's private param() invokable: it fires when the dynamic member-call invokes request.param() with zero arguments at runtime. The input at fault is the missing name argument (the query/path parameter key to look up). Any scripted call to param() without a string name — typically from JS-like request chaining — triggers this sentinel RuntimeException.
Solutions
- Pass the parameter name: request.param('id')
- If the name comes from a variable, verify the variable is non-null/non-empty before the call
- Check generated/configured script strings for an elided argument
Example fix
// before
var v = request.param();
// after
var v = request.param('userId'); Defensive patterns
Strategy: type-guard
Validate before calling
// ensure the argument is present and non-empty before the call
if (name == null || name.isEmpty()) throw new IllegalArgumentException("param name required"); Type guard
function requireArg(name, args) { if (args == null || args.length === 0) throw new Error('missing argument for param()'); return name; } Try / catch
try { var v = request.param('id'); } catch (RuntimeException e) { /* missing-argument misuse; fix the call site */ } Prevention
- Always pass the parameter name to param()
- Validate name-bearing variables are non-empty before interpolation into scripts
- Review auto-generated or templated script strings for dropped arguments
When it happens
Trigger: Invoking request.param() with zero arguments in a script/expression, e.g. request.param() instead of request.param('name').
Common situations: Copy-paste deleting the argument, dynamic generation of the call where the variable holding the param name was empty/null and dropped, typo leaving the parenthesis empty.
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
- missing argument for paramValues()
- missing argument for paramInt()
- missing argument for paramJson()
- missing argument for header()
- missing argument for headerValues()
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/8376eaed48b6238a.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/http/HttpRequest.java:543
if (headers != null) {
headers.forEach((name, values) -> {
if (values != null && !values.isEmpty()) {
builder.header(name, values);
}
});
}
if (body != null) {
builder.body(getBodyConverted());
}
return builder;
}
private JavaInvokable param() {
return args -> {
if (args.length > 0) {
return getParam(args[0] + "");
} else {
throw new RuntimeException("missing argument for param()");
}
};
}
private JavaInvokable paramValues() {
return args -> {
if (args.length > 0) {
return getParamValues(args[0] + "");
} else {
throw new RuntimeException("missing argument for paramValues()");
}
};
}
private JavaInvokable paramInt() {
return args -> {
if (args.length > 0) {
String val = getParam(args[0] + "");View on GitHub (pinned to a22eb90246)