{"record":{"id":"18c99613559fd461","repo":"karatelabs/karate","slug":"invalid-ignore-ignore","errorCode":null,"errorMessage":"Invalid ignore: ${ignore}","messagePattern":"Invalid ignore: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"karate-image/src/main/resources/META-INF/karate-ext/static/resemble.js","lineNumber":1022,"sourceCode":"    function applyIgnore(api, ignore, customTolerance) {\n        switch (ignore) {\n            case \"nothing\":\n                api.ignoreNothing();\n                break;\n            case \"less\":\n                api.ignoreLess();\n                break;\n            case \"antialiasing\":\n                api.ignoreAntialiasing();\n                break;\n            case \"colors\":\n                api.ignoreColors();\n                break;\n            case \"alpha\":\n                api.ignoreAlpha();\n                break;\n            default:\n                throw new Error(\"Invalid ignore: \" + ignore);\n        }\n\n        api.setupCustomTolerance(customTolerance);\n    }\n\n    resemble.compare = function (image1, image2, options, cb) {\n        var callback;\n        var opt;\n\n        if (typeof options === \"function\") {\n            callback = options;\n            opt = {};\n        } else {\n            callback = cb;\n            opt = options || {};\n        }\n\n        var res = resemble(image1);","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-image/src/main/resources/META-INF/karate-ext/static/resemble.js#L1004-L1040","documentation":"resemble.compare() accepts an options.ignore string that selects which color channel comparison ignores. Only undefined, 'none', 'red', 'green', 'blue', 'alpha' are accepted; anything else hits the default branch and throws. It is a strict enum validation on the caller-supplied options object.","triggerScenarios":"Calling resemble.compare(img1, img2, {ignore: 'transparency'}) or any misspelled channel name such as 'Alpha', 'redes', or 'colour' instead of the exact supported strings.","commonSituations":"Typos in ignore options, casing mistakes, or copying option values from a different diff library with richer enums.","solutions":["Use one of the exact values: undefined/'none', 'red', 'green', 'blue', 'alpha'","Lowercase/trim the option value before passing it","Validate options against the allowed set in your wrapper before calling compare"],"exampleFix":"// before\nresemble.compare(a, b, { ignore: 'Alpha' }, cb);\n// after\nresemble.compare(a, b, { ignore: 'alpha' }, cb);","handlingStrategy":"validation","validationCode":"const ALLOWED = [undefined, 'none', 'red', 'green', 'blue', 'alpha'];\nif (!ALLOWED.includes(options && options.ignore)) throw new Error('ignore must be one of ' + ALLOWED.join(', '));","typeGuard":"function isValidIgnore(v) { return v === undefined || ['none','red','green','blue','alpha'].includes(v); }","tryCatchPattern":"try { resemble.compare(a, b, opts, cb); } catch (e) { if (String(e.message).startsWith('Invalid ignore:')) { opts.ignore = 'none'; resemble.compare(a, b, opts, cb); } else { throw e; } }","preventionTips":["Copy ignore values exactly from resemble's documented enum","Normalize options.ignore with toLowerCase() before use","Centralize compare() options in one validated helper"],"tags":["javascript","image-diff","invalid-enum"],"backgroundTag":"invalid-enum-value","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"}