{"record":{"id":"901b6fb4075a335a","repo":"karatelabs/karate","slug":"image-resolve-name-is-required","errorCode":null,"errorMessage":"image.resolve: 'name' is required","messagePattern":"image\\.resolve: 'name' is required","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-image/src/main/java/io/karatelabs/ext/image/ImageApi.java","lineNumber":319,"sourceCode":"        Map<String, Object> embed = new LinkedHashMap<>();\n        embed.put(\"name\", \"image-comparison\");\n        embed.put(\"parts\", parts);\n        embed.put(\"meta\", meta);\n        return embed;\n    }\n\n    private static Map<String, Object> part(String role, byte[] data) {\n        Map<String, Object> p = new LinkedHashMap<>();\n        p.put(\"role\", role);\n        p.put(\"data\", data);   // mime auto-detected by karate.embed from the bytes\n        return p;\n    }\n\n    // ---- resolve (name → absolute baseline + options paths) ----\n\n    private Object resolveVerb(Object... args) {\n        if (args.length == 0 || str(args[0]) == null) {\n            throw new RuntimeException(\"image.resolve: 'name' is required\");\n        }\n        return resolve(str(args[0]));\n    }\n\n    private Map<String, Object> resolve(String name) {\n        String base = stripExt(name);\n        boolean hasExt = !base.equals(name);\n        String baselineLeaf = hasExt ? name : findBaselineLeaf(base);\n        String baselineJoined = join(str(config.get(\"baselineDir\")), baselineLeaf);\n\n        Map<String, Object> out = new LinkedHashMap<>();\n        out.put(\"baselinePath\", absolute(baselineJoined));\n        out.put(\"optionsPath\", absolute(join(optionsDir(), base + \".json\")));\n        out.put(\"baselineExists\", resourceExists(baselineJoined));\n        return out;\n    }\n\n    /**","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-image/src/main/java/io/karatelabs/ext/image/ImageApi.java#L301-L337","documentation":"The image.resolve verb maps a baseline name to absolute baseline and options paths. It requires the first argument to be a non-empty name; with no args or a null/unresolvable first arg it throws RuntimeException with this message.","triggerScenarios":"karate.call('image.resolve') with zero arguments, or with a first argument that str() maps to null (null, or an object/array rather than a string).","commonSituations":"Scripting resolution dynamically and the variable holding the name is null; calling resolve programmatically without args to 'probe' behavior; passing the bytes of an image instead of its name by mistake.","solutions":["Pass the baseline name as a string: karate.call('image.resolve', 'screenshot-home')","Ensure the variable holding the name is set and is a String before calling","If you have a path instead of a name, use the path directly rather than the resolve verb"],"exampleFix":"// before\nvar name = karate.get('baselineName'); // null\nkarate.call('image.resolve', name);\n// after\nkarate.set('baselineName', 'screenshot-home');\nkarate.call('image.resolve', karate.get('baselineName'));","handlingStrategy":"validation","validationCode":"# karate\n* if (!baselineName) karate.abort('baselineName must be set before image.resolve')\n* def resolved = karate.call('image.resolve', baselineName)","typeGuard":null,"tryCatchPattern":"try { return karate.call('image.resolve', name); } catch (Exception e) { if (('' + e).contains(\"'name' is required\")) throw new IllegalStateException(\"image.resolve called without a name — baselineName=\" + name); throw e; }","preventionTips":["Initialize the baseline-name variable at the top of the feature","Pass names as plain strings, never as maps or nulls","Keep baseline naming in one shared helper"],"tags":["karate","image-comparison","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"}