karatelabs/karate · error · RuntimeException
karate.callSingle() requires at least one argument (path)
Error message
karate.callSingle() requires at least one argument (path)
What it means
karate.callSingle() needs at least one argument: the path of the feature or JS file to execute once per suite. Karate throws this when the call has zero arguments, because there is no target to run or cache.
Solutions
- Supply the path as the first argument: karate.callSingle('classpath:utils.js').
- If extra data is needed, pass it as the second argument: karate.callSingle(path, arg).
- Assert the path variable is non-empty before invoking (karate.log or a fail-fast check).
Example fix
// before
karate.callSingle();
// after
karate.callSingle('classpath:utils/token.js'); Defensive patterns
Strategy: validation
Validate before calling
if (!path || typeof path !== 'string') { throw new Error('callSingle path required'); } karate.callSingle(path); Type guard
function isValidPath(p) { return typeof p === 'string' && p.trim().length > 0; } Try / catch
try { karate.callSingle(path); } catch (e) { if (String(e.message).includes('requires at least one argument')) { karate.log('callSingle missing path'); } throw e; } Prevention
- Always supply the target path as the first argument
- Verify dynamic path variables resolve before the call
- Pass extra data as the optional second argument, not a substitute for the path
When it happens
Trigger: `karate.callSingle()` invoked with no arguments; a path variable that is undefined/null at call time and not passed through.
Common situations: Refactoring call expressions and losing the argument; conditional paths that resolve to nothing; copy-paste of callSingle without its target path.
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
- karate.callonce() requires at least one argument (feature…
- karate.callSingle() is not available in this context
- configure() needs two arguments: key and value
- embed() needs at least one argument: data
- read() needs at least one argument
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/3fc7eb27739909f2.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/KarateJsBase.java:408
throw new RuntimeException("karate.callonce() requires at least one argument (feature path)");
}
String path = args[0].toString();
Object arg = args.length > 1 ? args[1] : null;
return rt.executeJsCallOnce(path, arg);
};
}
/**
* karate.callSingle() - Execute a feature/JS file once per Suite and cache the result.
*/
JavaInvokable callSingle() {
return args -> {
ScenarioRuntime rt = getRuntime();
if (rt == null) {
throw new RuntimeException("karate.callSingle() is not available in this context");
}
if (args.length == 0) {
throw new RuntimeException("karate.callSingle() requires at least one argument (path)");
}
String path = args[0].toString();
Object arg = args.length > 1 ? args[1] : null;
return rt.executeCallSingle(path, arg);
};
}
/**
* karate.configure() - Apply configuration from JavaScript.
*/
JavaInvokable configure() {
return args -> {
if (args.length < 2) {
throw new RuntimeException("configure() needs two arguments: key and value");
}
String key = args[0].toString();
Object value = args[1];
ScenarioRuntime rt = getRuntime();View on GitHub (pinned to a22eb90246)