karatelabs/karate · error · ParserException
' ' is not a valid parameter name in strict mode
Error message
'${name}' is not a valid parameter name in strict mode What it means
In strict mode, `eval` and `arguments` are not valid parameter (binding) names. Karate collects all bound names of a function's parameter list — including destructured bindings — and rejects any occurrence when strict. This applies to plain and arrow functions alike.
Solutions
- Rename the parameter (e.g. `args`, `argList`).
- Update all uses of the parameter inside the function body to the new name.
- If the intent was the implicit `arguments` object, use rest parameters instead: `function f(...args) {}`.
Example fix
// before "use strict"; const log = (arguments) => console.log(arguments); // after "use strict"; const log = (...args) => console.log(args);
Defensive patterns
Strategy: validation
Validate before calling
function assertNoReservedParams(fnSrc) {
const header = fnSrc.slice(0, fnSrc.indexOf(')') + 1);
const bad = header.match(/[\s(,{[](eval|arguments)\b/);
if (bad) throw new Error("parameter '" + bad[1] + "' is invalid in strict mode");
} Try / catch
try {
karate.eval(script);
} catch (e) {
if (String(e.message).includes('is not a valid parameter name in strict mode')) {
// rename the offending parameter and its uses, then re-evaluate
} else throw e;
} Prevention
- Use `...args` rest parameters instead of naming a parameter `arguments`.
- Keep a reserved-word list (eval, arguments) out of parameter names in code generators.
- Run embedded scripts under Node --use-strict in CI to catch these early.
When it happens
Trigger: Declaring `function f(eval) {}`, `(arguments) => ...`, or destructured forms like `function f({eval: e}) {}` in strict-mode Karate JS.
Common situations: Callback signatures naively naming a parameter `arguments`; refactored code where a parameter was named after the built-in; code moved into strict scope (module/class).
Related errors
- ' ' is not a valid function name in strict mode
- duplicate parameter name
- ' ' is not a valid binding name in strict mode
- 'await' is a reserved word in a class static initialization…
- identifier ' ' has already been declared
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/4aca101e40806c62.
Report an issue: GitHub.
Appendix: source
Thrown at karate-js/src/main/java/io/karatelabs/parser/JsParser.java:1054
nonSimple = true;
break;
}
}
if (!strict && !isArrow && !nonSimple) {
return;
}
List<String> names = new ArrayList<>();
for (int i = 0, n = args.size(); i < n; i++) {
Node arg = args.get(i);
if (arg.isToken() || arg.type != NodeType.FN_DECL_ARG) {
continue;
}
collectBindingBoundNames(arg, names);
}
if (strict) {
for (String name : names) {
if (isEvalOrArguments(name)) {
throw new ParserException(
"'" + name + "' is not a valid parameter name in strict mode");
}
}
}
if (strict || isArrow || nonSimple) {
String dup = firstDuplicate(names);
if (dup != null) {
throw new ParserException(
"duplicate parameter name '" + dup + "' is not allowed here");
}
}
}
/** A FormalParameter is non-simple if it is a destructuring pattern, carries a
* default initializer, or is a rest element — any of which makes the whole
* parameter list non-simple, so duplicate bound names become an early error. */
private static boolean isNonSimpleParam(Node arg) {
for (int i = 0, n = arg.size(); i < n; i++) {View on GitHub (pinned to a22eb90246)