{"record":{"id":"c9d3640c12d6a364","repo":"karatelabs/karate","slug":"start-needs-at-least-one-argument-feature-path-or-config-map","errorCode":null,"errorMessage":"start() needs at least one argument: feature path or config map","messagePattern":"start\\(\\) needs at least one argument: feature path or config map","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KarateJs.java","lineNumber":939,"sourceCode":"            }\n            return handle;\n        };\n    }\n\n    /**\n     * karate.start() - Start a mock server from a feature file.\n     * Usage:\n     * <pre>\n     * var server = karate.start('api.feature');\n     * var server = karate.start({ mock: 'api.feature', port: 8080 });\n     * var server = karate.start({ mock: 'api.feature', port: 8443, ssl: true });\n     * </pre>\n     */\n    @SuppressWarnings(\"unchecked\")\n    private JavaInvokable start() {\n        return args -> {\n            if (args.length == 0) {\n                throw new RuntimeException(\"start() needs at least one argument: feature path or config map\");\n            }\n            Object arg = args[0];\n            MockServer.Builder builder;\n\n            if (arg instanceof String path) {\n                // Simple path: karate.start('api.feature')\n                builder = MockServer.feature(root.resolve(path));\n            } else if (arg instanceof Map) {\n                // Config map: karate.start({ mock: 'api.feature', port: 8080 })\n                Map<String, Object> config = (Map<String, Object>) arg;\n                String mockPath = (String) config.get(\"mock\");\n                if (mockPath == null) {\n                    throw new RuntimeException(\"start() config requires 'mock' key with feature path\");\n                }\n                builder = MockServer.feature(root.resolve(mockPath));\n\n                if (config.containsKey(\"port\")) {\n                    builder.port(((Number) config.get(\"port\")).intValue());","sourceCodeStart":921,"sourceCodeEnd":957,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KarateJs.java#L921-L957","documentation":"`karate.start()` launches a Karate mock server and requires either a feature file path (String) or a config Map (e.g. { mock: 'api.feature', port: 8080 }). With zero arguments there is no feature to serve, so the library throws this descriptive error naming both accepted forms.","triggerScenarios":"Calling karate.start() with no arguments, or an invocation where all arguments were dropped (spread of empty array, apply with empty args list).","commonSituations":"Refactoring that removed the feature path; assuming start() picks up a default config file like karate-config.js does; dynamically resolved path variable left undefined so the call effectively passes nothing; confusing karate.start() with karate.setup() or a background hook that takes no args.","solutions":["Pass the feature path: karate.start('classpath:mocks/api.feature') or karate.start('api.feature') relative to the script root","Pass a config Map: karate.start({ mock: 'api.feature', port: 8080 })","If the path is dynamic, ensure it resolves to a non-empty value before calling","Verify you are not confusing start() with an argument-less lifecycle hook from another API"],"exampleFix":"// before\nkarate.start() // throws\n// after\nvar server = karate.start({ mock: 'animals-mock.feature', port: 8080 });","handlingStrategy":"validation","validationCode":"// JS\nif (typeof featureOrConfig === 'undefined' || featureOrConfig === null) throw new Error('karate.start() requires a feature path or config map');\nvar server = karate.start(featureOrConfig);","typeGuard":"function isStartArg(v) { return typeof v === 'string' || (v !== null && typeof v === 'object'); }","tryCatchPattern":"try { var server = karate.start(cfg); } catch (e) { if (('' + e).indexOf('start() needs at least one argument') !== -1) { karate.log('start() called without feature path or config'); } throw e; }","preventionTips":["Always pass a feature path or { mock: ... } map","Check dynamic path variables resolve before calling","Do not confuse start() with argument-less lifecycle hooks"],"tags":["javascript","mock-server","missing-argument"],"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"}