{"record":{"id":"b8832bb96c80aa5c","repo":"karatelabs/karate","slug":"failed-to-load-config-from-configpath","errorCode":null,"errorMessage":"Failed to load config from: <configPath>","messagePattern":"Failed to load config from: <configPath>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/KaratePom.java","lineNumber":183,"sourceCode":"     * @throws RuntimeException if file cannot be read or parsed\n     */\n    public static KaratePom load(String configPath) {\n        return load(Path.of(configPath));\n    }\n\n    /**\n     * Load configuration from a JSON file.\n     *\n     * @param configPath path to the JSON config file\n     * @return parsed KaratePom\n     * @throws RuntimeException if file cannot be read or parsed\n     */\n    public static KaratePom load(Path configPath) {\n        try {\n            String content = Files.readString(configPath);\n            return parse(content);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Failed to load config from: \" + configPath, e);\n        }\n    }\n\n    /**\n     * Parse configuration from a JSON string.\n     *\n     * @param json JSON string\n     * @return parsed KaratePom\n     * @throws RuntimeException if JSON is invalid\n     */\n    public static KaratePom parse(String json) {\n        Json j = Json.of(json);\n        if (!j.isObject()) {\n            throw new RuntimeException(\"Invalid config: expected JSON object\");\n        }\n        KaratePom config = new KaratePom();\n\n        // Parse paths","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/KaratePom.java#L165-L201","documentation":"KaratePom.load(configPath) reads the karate-pom.json file from disk and parses it; any IO or parse failure is wrapped in 'Failed to load config from: <path>' with the original exception as cause. Typically the file does not exist or is unreadable.","triggerScenarios":"Calling load() with a path to a missing, deleted, permission-blocked, or unreadable karate-pom.json, or a file that fails JSON parsing.","commonSituations":"Running from a working directory where the config path is relative and wrong; typo'd file name; config not committed to the repo so CI fails; unreadable permissions.","solutions":["Verify the file exists at the printed path (ls/cat it)","Use an absolute path or fix the relative path relative to the working directory","Check file read permissions","Inspect the nested 'caused by' to distinguish file-not-found from JSON parse errors"],"exampleFix":"// before\nKaratePom.load(Path.of(\"karate-pom.json\"));\n// after\nPath cfg = Path.of(\"karate-pom.json\");\nif (!Files.exists(cfg)) throw new IllegalStateException(\"config missing: \" + cfg.toAbsolutePath());\nKaratePom.load(cfg);","handlingStrategy":"try-catch","validationCode":"// Java: check readability before load\nif (!Files.isReadable(configPath)) throw new IllegalStateException(\"unreadable config: \" + configPath);\nKaratePom.load(configPath);","typeGuard":"static boolean isReadableConfig(Path p) { return p != null && Files.isRegularFile(p) && Files.isReadable(p); }","tryCatchPattern":"try {\n    KaratePom pom = KaratePom.load(configPath);\n} catch (RuntimeException e) {\n    throw new IllegalStateException(\"cannot load karate-pom at \" + configPath + \": \" + e.getCause(), e);\n}","preventionTips":["Commit karate-pom.json so CI has it","Prefer absolute paths or verify the working directory","Check the wrapped cause to separate file-not-found from parse errors"],"tags":["config","file-io","runtime-exception"],"backgroundTag":"file-read-failed","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"}