karatelabs/karate · error · RuntimeException
configure() needs two arguments: key and value
Error message
configure() needs two arguments: key and value
What it means
karate.configure(key, value) sets a configuration option at runtime and requires exactly the key and value arguments. Karate throws this when fewer than two arguments are supplied, since a key alone (or no arguments) cannot configure anything.
Solutions
- Pass both key and value: karate.configure('headers', {Authorization: 'Basic ...'}).
- If the value is an object/function (e.g. retry config), supply it as the second argument, not merged into the key.
- Check spelling and arity of the call; karate.configure never accepts a single options map.
Example fix
// before
karate.configure('retry');
// after
karate.configure('retry', { count: 3, interval: 1000 }); Defensive patterns
Strategy: validation
Validate before calling
if (key == null || value === undefined) { throw new Error('configure needs key and value'); } karate.configure(key, value); Type guard
function canConfigure(key, value) { return typeof key === 'string' && key.length > 0 && value !== undefined; } Try / catch
try { karate.configure(key, value); } catch (e) { if (String(e.message).includes('needs two arguments')) { karate.log('configure arity error for key: ' + key); } throw e; } Prevention
- Always pass key and value as separate arguments
- Never use a single options-map form
- Check arity when porting configure calls between languages
When it happens
Trigger: `karate.configure('retry')` or `karate.configure()` called from JS with one or zero arguments.
Common situations: Typos in configure calls; porting Java-side configure(key, value) to JS incorrectly; assuming a single object argument form is supported (it is not — key and value must be separate).
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() requires at least one argument (path)
- embed() needs at least one argument: data
- read() needs at least one argument
- eval() needs one argument
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/18427adf1d25eceb.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/KarateJsBase.java:422
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();
if (rt != null) {
rt.configure(key, value);
}
return null;
};
}
/**
* Returns system properties available via karate.properties['key'].
*/
Map<String, String> getProperties() {
Suite suite = getSuite();
if (suite != null) {
return suite.getSystemProperties();View on GitHub (pinned to a22eb90246)