{"record":{"id":"7092d66bf453a32a","repo":"karatelabs/karate","slug":"no-scenario-found-with-setup-tag-and-name-name","errorCode":null,"errorMessage":"no scenario found with @setup tag[ and name '<name>']","messagePattern":"no scenario found with @setup tag\\[ and name '<name>'\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java","lineNumber":521,"sourceCode":"            logger.warn(\"Failed to evaluate {}: {}\", displayName, e.getMessage());\n            throw new RuntimeException(\"Config evaluation failed: \" + displayName + \" - \" + e.getMessage(), e);\n        }\n    }\n\n    /**\n     * Execute the @setup scenario and return all its variables.\n     */\n    public Map<String, Object> executeSetup(String name) {\n        if (featureRuntime == null) {\n            throw new RuntimeException(\"karate.setup() requires a feature context\");\n        }\n        Scenario setupScenario = scenario.getFeature().getSetup(name);\n        if (setupScenario == null) {\n            String message = \"no scenario found with @setup tag\";\n            if (name != null) {\n                message = message + \" and name '\" + name + \"'\";\n            }\n            throw new RuntimeException(message);\n        }\n        // Run the setup scenario without background\n        ScenarioRuntime sr = new ScenarioRuntime(featureRuntime, setupScenario);\n        sr.setSkipBackground(true);\n        sr.call();\n        // The setup runtime re-evaluates config, and a failure there is now captured rather than\n        // thrown from the constructor. call()'s failed result is discarded here, so without this the\n        // caller gets an empty variable map and the config error resurfaces as a baffling\n        // \"x is not defined\" wherever a setup variable was expected. Fail where the cause is.\n        Throwable setupConfigError = sr.getConfigError();\n        if (setupConfigError != null) {\n            throw setupConfigError instanceof RuntimeException re ? re : new RuntimeException(setupConfigError);\n        }\n        return sr.getAllVariables();\n    }\n\n    /**\n     * Execute the @setup scenario with caching (only runs once per feature).","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java#L503-L539","documentation":"executeSetup looks up the @setup scenario via feature.getSetup(name). If the feature contains no @setup-tagged scenario matching the optional name argument, a RuntimeException with this message is thrown, naming the requested setup when one was supplied. It is a feature-authoring error, not a runtime failure.","triggerScenarios":"karate.setup() with no argument when the feature has no @setup scenario at all; karate.setup('name') when no @setup scenario carries that exact name/tag combination; a typo in the setup name; the @setup tag missing from the intended scenario.","commonSituations":"Copying scenarios between features without copying the @setup block; renaming a setup scenario but not all karate.setup('name') call sites; assuming setup is inherited from a called feature (it is not — setup is per-feature).","solutions":["Add a scenario tagged @setup to the current feature (with the matching name if karate.setup('name') is used).","Verify exact spelling of the name passed to karate.setup('name') against the setup scenario's name.","Remember the @setup scenario must be in the same feature — call the other feature with karate.call() instead if setup lives elsewhere.","Call karate.setup() with no argument only when the feature has exactly one default @setup scenario."],"exampleFix":"// before\n# feature has no setup, but JS does:\n* def data = karate.setup()\n\n// after\n@setup\nScenario:\n  * def data = { userId: 1 }\n\n# then\n* def data = karate.setup()","handlingStrategy":"validation","validationCode":"// before karate.setup('name'), confirm the setup exists in THIS feature:\n// @setup\n// Scenario: makeData  <-- name must match exactly","typeGuard":null,"tryCatchPattern":"try {\n    var data = karate.setup('makeData');\n} catch (e) {\n    if (String(e).indexOf('no scenario found with @setup tag') >= 0) {\n        karate.log('setup missing; falling back to inline data');\n        data = { userId: 1 };\n    } else { throw e; }\n}","preventionTips":["Keep one default @setup scenario per feature that needs setup","Grep call sites for karate.setup('<name>') when renaming setup scenarios","Remember @setup is per-feature — copy it when copying scenarios across features","Omit the name argument only when a single default setup exists"],"tags":["setup","scenario-tags","feature-authoring"],"backgroundTag":"resource-not-found","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}