karatelabs/karate · warning
configure logging.mask.patterns
Error message
configure logging.mask.patterns[{}] missing 'regex' — skipped What it means
When parsing a `configure logging.mask` map, each entry in the `patterns` list must contain a `regex` key. If it is missing, LogMask skips that entry and logs this warning instead of failing the whole config eval, so the remaining mask rules still apply.
Solutions
- Add the required `regex` key to every entry in the patterns list
- Check for key-name typos: the key must be exactly `regex`
- If building the config dynamically, filter out entries without a regex before configuring
- Check the warned index in the message to locate the offending entry in the list
Example fix
// before
karate.configure('logging.mask', { patterns: [{ replacement: '***' }] })
// after
karate.configure('logging.mask', { patterns: [{ regex: '[0-9]{16}', replacement: '***' }] }) Defensive patterns
Strategy: validation
Validate before calling
var patterns = List.of(Map.of("regex", "[0-9]{16}", "replacement", "***"));
for (var p : patterns) {
if (!p.containsKey("regex") || p.get("regex") == null)
throw new IllegalArgumentException("mask pattern entry missing 'regex'");
} Type guard
boolean hasRegex(Map<?,?> pm) { return pm.get("regex") instanceof String s && !s.isBlank(); } Prevention
- Always include a `regex` key in every patterns entry
- Validate mask config keys before calling configure
- Build patterns from a shared constant/helper to avoid key typos
When it happens
Trigger: Calling `karate.configure('logging.mask', { patterns: [{ replacement: '***' }] })` — a pattern entry without a `regex` key; also when regex is present but null (e.g. built dynamically from a variable that is null).
Common situations: Typo'd key name (`pattern`, `regEx`, `expression`) instead of `regex`; dynamically assembled mask config where a value failed to load; copy-paste of a headers/jsonPaths-style entry into the patterns list.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- configure logging.mask.patterns
- configure logging.mask: no usable rules — set at least one…
- configure logging.mask: unknown key
- configure ' ' is deprecated; use 'configure logging = }
- configure 'logging' expects a map, got
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/5daa29b626533f31.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/output/LogMask.java:114
}
}
}
List<String> jsonPaths = new ArrayList<>();
if (map.get("jsonPaths") instanceof List<?> list) {
for (Object item : list) {
if (item != null) {
jsonPaths.add(item.toString());
}
}
}
List<PatternRule> patternRules = new ArrayList<>();
if (map.get("patterns") instanceof List<?> list) {
int idx = 0;
for (Object item : list) {
if (item instanceof Map<?, ?> pm) {
Object regex = pm.get("regex");
if (regex == null) {
logger.warn("configure logging.mask.patterns[{}] missing 'regex' — skipped", idx);
idx++;
continue;
}
Object rep = pm.get("replacement");
String repStr = rep == null ? replacement : rep.toString();
try {
patternRules.add(new PatternRule(Pattern.compile(regex.toString()), repStr));
} catch (PatternSyntaxException e) {
// Skip rather than fail-fast — a typo in one rule shouldn't blow up
// the whole config-js eval. The warn names the entry so the user
// can find it. Other rules in the same mask still apply.
logger.warn("configure logging.mask.patterns[{}] invalid regex '{}': {} — skipped",
idx, regex, e.getDescription());
}
}
idx++;
}
}View on GitHub (pinned to a22eb90246)