{"record":{"id":"0864b9f984fef509","repo":"karatelabs/karate","slug":"boot-ext-name-is-null-or-empty","errorCode":null,"errorMessage":"boot.ext: name is null or empty","messagePattern":"boot\\.ext: name is null or empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/BootBinding.java","lineNumber":213,"sourceCode":"    }\n\n    /** {@code boot.log('...')} — INFO log with [boot] prefix. */\n    public void log(Object msg) {\n        logger.info(\"[boot] {}\", msg == null ? \"null\" : msg.toString());\n    }\n\n    /**\n     * {@code boot.ext('name')} — resolve + construct + register an ext.\n     *\n     * <p>Resolution by name convention: {@code 'openapi'} →\n     * {@code io.karatelabs.ext.openapi.OpenapiExt}. The class is loaded from\n     * the runtime classloader; missing ext → boot-time failure (suite fails loud).</p>\n     *\n     * <p>Same name twice returns the same singleton instance.</p>\n     */\n    public Ext ext(String name) {\n        if (name == null || name.isBlank()) {\n            throw new IllegalArgumentException(\"boot.ext: name is null or empty\");\n        }\n        // Singleton-per-name within this BootBinding (which is itself per-Suite).\n        for (Ext existing : exts) {\n            if (name.equals(extShortName(existing))) {\n                return existing;\n            }\n        }\n        String className = extClassName(name);\n        Ext ext;\n        try {\n            Class<?> cls = Class.forName(className);\n            Object instance = cls.getDeclaredConstructor().newInstance();\n            if (!(instance instanceof Ext)) {\n                throw new RuntimeException(\n                        \"boot.ext('\" + name + \"'): \" + className\n                                + \" does not implement io.karatelabs.core.Ext\");\n            }\n            ext = (Ext) instance;","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/BootBinding.java#L195-L231","documentation":"BootBinding.ext(name) loads a karate extension by name-convention class resolution, and a null or blank name cannot be resolved, so an IllegalArgumentException is thrown immediately. Extension names are looked up as singletons per Suite; the name drives the fully-qualified class name construction.","triggerScenarios":"Calling boot.ext(null), boot.ext(''), or boot.ext('   ') — directly or via a variable that is null/empty at boot time.","commonSituations":"Extension name supplied from config/env that is unset; typo leaving an empty string; generated boot config where the ext name placeholder was never filled.","solutions":["Pass a non-empty extension short name, e.g. boot.ext('myext').","Default or validate the variable feeding the call before boot.ext executes.","Remove the boot.ext call entirely if no extension is needed for this suite."],"exampleFix":"// before\nvar extName = karate.properties.get('karate.ext'); boot.ext(extName); // may be null\n// after\nvar extName = karate.properties.get('karate.ext');\nif (extName) boot.ext(extName);","handlingStrategy":"validation","validationCode":"// before calling boot.ext(name)\nif (name == null || name.isBlank()) throw new IllegalArgumentException(\"extension name required\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide defaults for extension names read from properties/env.","Skip boot.ext entirely when no extension is configured.","Use literal extension names in boot scripts."],"tags":["boot","extension","null-argument"],"backgroundTag":"null-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"}