{"record":{"id":"b1495fe44a3203c1","repo":"karatelabs/karate","slug":"configure-logging-mask-no-usable-rules-set-at-least-one-of","errorCode":null,"errorMessage":"configure logging.mask: no usable rules — set at least one of headers / jsonPaths / patterns. mask is OFF.","messagePattern":"configure logging\\.mask: no usable rules — set at least one of headers / jsonPaths / patterns\\. mask is OFF\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"karate-core/src/main/java/io/karatelabs/output/LogMask.java","lineNumber":137,"sourceCode":"                    String repStr = rep == null ? replacement : rep.toString();\n                    try {\n                        patternRules.add(new PatternRule(Pattern.compile(regex.toString()), repStr));\n                    } catch (PatternSyntaxException e) {\n                        // Skip rather than fail-fast — a typo in one rule shouldn't blow up\n                        // the whole config-js eval. The warn names the entry so the user\n                        // can find it. Other rules in the same mask still apply.\n                        logger.warn(\"configure logging.mask.patterns[{}] invalid regex '{}': {} — skipped\",\n                                idx, regex, e.getDescription());\n                    }\n                }\n                idx++;\n            }\n        }\n        JavaCallable enableForUri = map.get(\"enableForUri\") instanceof JavaCallable c ? c : null;\n        if (headers.isEmpty() && jsonPaths.isEmpty() && patternRules.isEmpty()) {\n            // User provided a mask map but every rule list is empty / invalid. Without this\n            // warn the mask silently does nothing, which is hard to debug.\n            logger.warn(\"configure logging.mask: no usable rules — set at least one of \"\n                    + \"headers / jsonPaths / patterns. mask is OFF.\");\n            return null;\n        }\n        return new LogMask(headers, jsonPaths, patternRules, replacement, enableForUri);\n    }\n\n    /**\n     * One-line description of mask rule counts, e.g.\n     * {@code \"3 headers, 2 jsonPaths, 1 pattern\"}. Used by the per-scenario\n     * \"mask active\" debug log so users can verify their config compiled.\n     */\n    public String describe() {\n        int h = maskedHeadersLower.size();\n        int j = jsonPaths.size();\n        int p = patternRules.size();\n        return h + (h == 1 ? \" header, \" : \" headers, \")\n                + j + (j == 1 ? \" jsonPath, \" : \" jsonPaths, \")\n                + p + (p == 1 ? \" pattern\" : \" patterns\");","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/output/LogMask.java#L119-L155","documentation":"A `logging.mask` configure map was supplied but none of its rule lists (`headers`, `jsonPaths`, `patterns`) yielded any usable rules, so masking would silently do nothing. The library warns and returns null — the mask is OFF — rather than installing an empty mask.","triggerScenarios":"`karate.configure('logging.mask', {})`; a mask map where all lists are empty arrays; a map where every patterns entry was skipped (missing/invalid regex, per errors 880/881) leaving zero usable rules.","commonSituations":"Configuring masking with keys mistyped so nothing was parsed (`header` instead of `headers`); all pattern regexes invalid so the list drained to empty; leftover empty mask config from removed rules.","solutions":["Add at least one rule under `headers`, `jsonPaths`, or `patterns`","Verify key spellings: `headers`, `jsonPaths`, `patterns` (case-sensitive)","If patterns were intended, fix the per-entry warnings (missing/invalid regex) logged before this one","Remove the empty mask configure call if masking is not needed"],"exampleFix":"// before\nkarate.configure('logging.mask', { patterns: [] })\n// after\nkarate.configure('logging.mask', { headers: ['Authorization'], jsonPaths: ['$.password'] })","handlingStrategy":"validation","validationCode":"if (headers.isEmpty() && jsonPaths.isEmpty() && patterns.isEmpty())\n    throw new IllegalStateException(\"logging.mask has no rules; mask would be OFF\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provide at least one rule in headers, jsonPaths, or patterns","Use exact key names: headers, jsonPaths, patterns","Remove empty mask configure calls; fix upstream per-entry warnings"],"tags":["logging","configuration","masking","empty-config"],"backgroundTag":"missing-required-config","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"}