{"record":{"id":"18427adf1d25eceb","repo":"karatelabs/karate","slug":"configure-needs-two-arguments-key-and-value","errorCode":null,"errorMessage":"configure() needs two arguments: key and value","messagePattern":"configure\\(\\) needs two arguments: key and value","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateJsBase.java","lineNumber":422,"sourceCode":"            if (rt == null) {\n                throw new RuntimeException(\"karate.callSingle() is not available in this context\");\n            }\n            if (args.length == 0) {\n                throw new RuntimeException(\"karate.callSingle() requires at least one argument (path)\");\n            }\n            String path = args[0].toString();\n            Object arg = args.length > 1 ? args[1] : null;\n            return rt.executeCallSingle(path, arg);\n        };\n    }\n\n    /**\n     * karate.configure() - Apply configuration from JavaScript.\n     */\n    JavaInvokable configure() {\n        return args -> {\n            if (args.length < 2) {\n                throw new RuntimeException(\"configure() needs two arguments: key and value\");\n            }\n            String key = args[0].toString();\n            Object value = args[1];\n            ScenarioRuntime rt = getRuntime();\n            if (rt != null) {\n                rt.configure(key, value);\n            }\n            return null;\n        };\n    }\n\n    /**\n     * Returns system properties available via karate.properties['key'].\n     */\n    Map<String, String> getProperties() {\n        Suite suite = getSuite();\n        if (suite != null) {\n            return suite.getSystemProperties();","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateJsBase.java#L404-L440","documentation":"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.","triggerScenarios":"`karate.configure('retry')` or `karate.configure()` called from JS with one or zero arguments.","commonSituations":"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).","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."],"exampleFix":"// before\nkarate.configure('retry');\n\n// after\nkarate.configure('retry', { count: 3, interval: 1000 });","handlingStrategy":"validation","validationCode":"if (key == null || value === undefined) { throw new Error('configure needs key and value'); } karate.configure(key, value);","typeGuard":"function canConfigure(key, value) { return typeof key === 'string' && key.length > 0 && value !== undefined; }","tryCatchPattern":"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; }","preventionTips":["Always pass key and value as separate arguments","Never use a single options-map form","Check arity when porting configure calls between languages"],"tags":["javascript","arguments","configure","karate"],"backgroundTag":"missing-required-argument","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}