{"record":{"id":"3fc7eb27739909f2","repo":"karatelabs/karate","slug":"karate-callsingle-requires-at-least-one-argument-path","errorCode":null,"errorMessage":"karate.callSingle() requires at least one argument (path)","messagePattern":"karate\\.callSingle\\(\\) requires at least one argument \\(path\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateJsBase.java","lineNumber":408,"sourceCode":"                throw new RuntimeException(\"karate.callonce() requires at least one argument (feature path)\");\n            }\n            String path = args[0].toString();\n            Object arg = args.length > 1 ? args[1] : null;\n            return rt.executeJsCallOnce(path, arg);\n        };\n    }\n\n    /**\n     * karate.callSingle() - Execute a feature/JS file once per Suite and cache the result.\n     */\n    JavaInvokable callSingle() {\n        return args -> {\n            ScenarioRuntime rt = getRuntime();\n            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();","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateJsBase.java#L390-L426","documentation":"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.","triggerScenarios":"`karate.callSingle()` invoked with no arguments; a path variable that is undefined/null at call time and not passed through.","commonSituations":"Refactoring call expressions and losing the argument; conditional paths that resolve to nothing; copy-paste of callSingle without its target path.","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)."],"exampleFix":"// before\nkarate.callSingle();\n\n// after\nkarate.callSingle('classpath:utils/token.js');","handlingStrategy":"validation","validationCode":"if (!path || typeof path !== 'string') { throw new Error('callSingle path required'); } karate.callSingle(path);","typeGuard":"function isValidPath(p) { return typeof p === 'string' && p.trim().length > 0; }","tryCatchPattern":"try { karate.callSingle(path); } catch (e) { if (String(e.message).includes('requires at least one argument')) { karate.log('callSingle missing path'); } throw e; }","preventionTips":["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"],"tags":["javascript","arguments","callsingle","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"}