{"record":{"id":"79a4969180969011","repo":"karatelabs/karate","slug":"at-least-one-feature-file-is-required","errorCode":null,"errorMessage":"at least one feature file is required","messagePattern":"at least one feature file is required","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/MockServer.java","lineNumber":330,"sourceCode":"\n        /**\n         * Evaluate embedded {@code #(...)} expressions found in request-derived data\n         * (request/requestHeaders/requestParams). OFF by default: attacker-controlled request\n         * data is treated as inert data, not Karate code. Only enable for trusted mocks that\n         * intentionally template off request content. Individual features can also opt in with\n         * {@code configure requestExpressionsEnabled = true}.\n         */\n        public Builder requestExpressionsEnabled(boolean requestExpressionsEnabled) {\n            this.requestExpressionsEnabled = requestExpressionsEnabled;\n            return this;\n        }\n\n        /**\n         * Start the mock server.\n         */\n        public MockServer start() {\n            if (features.isEmpty()) {\n                throw new RuntimeException(\"at least one feature file is required\");\n            }\n\n            // Create handler - use ReloadingHandler wrapper if watch mode is enabled\n            Function<HttpRequest, HttpResponse> requestHandler;\n            MockHandler handler;\n\n            if (watch) {\n                ReloadingHandler reloadingHandler = new ReloadingHandler(features, args, pathPrefix, javaBridgeEnabled, requestExpressionsEnabled);\n                handler = reloadingHandler.getHandler();\n                requestHandler = reloadingHandler;\n                logger.info(\"watch mode enabled - features will be reloaded when modified\");\n            } else {\n                handler = new MockHandler(features, args, pathPrefix, javaBridgeEnabled, requestExpressionsEnabled);\n                requestHandler = handler;\n            }\n\n            SslContext sslContext = null;\n            if (ssl) {","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/MockServer.java#L312-L348","documentation":"MockServer.start() refuses to boot a mock server with zero registered features, since there would be nothing to serve. Karate throws this eagerly at startup instead of silently starting an empty server.","triggerScenarios":"Calling MockServer.builder().start() without any .feature(...) call, or building features from a path/glob that resolved to nothing at build time.","commonSituations":"Wrong classpath path to the feature file; using a glob that matched no files; feature() calls accidentally removed or guarded by a condition; features added to a different builder instance than the one started.","solutions":["Call .feature(path) with a valid feature file path before start()","If loading by package/glob, verify resources are on the classpath (check target/test-classes or the jar)","Log features.size() before start() to confirm the builder collected the features","Ensure you start the same builder instance you configured"],"exampleFix":"// before\nMockServer server = MockServer.builder().http(8080).build().start();\n// after\nMockServer server = MockServer.builder()\n        .feature(\"classpath:mocks/users-mock.feature\")\n        .http(8080).build().start();","handlingStrategy":"validation","validationCode":"if (features == null || features.isEmpty()) throw new IllegalStateException(\"no features configured for MockServer\");","typeGuard":null,"tryCatchPattern":"try { server.start(); } catch (RuntimeException e) { if (\"at least one feature file is required\".equals(e.getMessage())) { log.error(\"MockServer built with zero features — check feature() calls and resource paths\"); } throw e; }","preventionTips":["Always pass explicit feature paths to the builder; avoid empty glob results","Assert the resource exists before building: getClass().getResource(path) != null","Log features.size() during test bootstrap"],"tags":["mock-server","configuration","startup","empty-input"],"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"}