karatelabs/karate · warning
configure logging.mask: unknown key
Error message
configure logging.mask: unknown key '{}' (known: {}) What it means
LogMask.fromMap() validates the keys of the configure logging.mask map against KNOWN_KEYS. Unknown keys do not abort configuration — each is warned about with the full list of known keys, and valid options (replacement, headers, etc.) are still applied. It indicates a typo or stale option in the mask configuration.
Solutions
- Compare your keys against the known list printed in the warning and fix the typo
- Remove keys that no longer exist in your Karate version (check the LogMask javadoc/changelog)
- Keep only supported keys (replacement, headers, ...) in the logging.mask map
- Add a startup assertion in CI that parses warnings to catch misconfiguration early
Example fix
// before
karate.configure('logging.mask', { replacment: '***', headers: ['Authorization'] });
// after
karate.configure('logging.mask', { replacement: '***', headers: ['Authorization'] }); Defensive patterns
Strategy: validation
Validate before calling
// JS: validate mask keys before configure
const known = ['replacement', 'headers'];
const mask = { replacement: '***', headers: ['Authorization'] };
for (const k of Object.keys(mask)) {
if (!known.includes(k)) throw new Error('unknown logging.mask key: ' + k);
}
karate.configure('logging.mask', mask); Prevention
- Copy logging.mask keys only from the current version's documentation
- Treat this warning as a typo signal — unknown keys are silently ignored
- Pin the Karate version and re-check mask options when upgrading
When it happens
Trigger: Calling configure logging.mask (e.g. in karate-config.js or a Feature Background) with a map containing a key not in LogMask.KNOWN_KEYS — typically a misspelled option or one removed/renamed in a newer Karate version.
Common situations: Typo like 'replacment' or 'header'; copying config from an older tutorial using a renamed key; IDE autocomplete lacking for the JS-side map literal.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- configure logging.mask: no usable rules — set at least one…
- configure logging.mask.patterns
- configure logging.mask.patterns
- 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/43ca68fb86e28be3.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/output/LogMask.java:87
List<String> jsonPaths,
List<PatternRule> patternRules,
String replacement,
JavaCallable enableForUri) {
this.maskedHeadersLower = maskedHeadersLower;
this.jsonPaths = jsonPaths;
this.patternRules = patternRules;
this.replacement = replacement;
this.enableForUri = enableForUri;
}
@SuppressWarnings("unchecked")
public static LogMask fromMap(Map<String, Object> map) {
if (map == null || map.isEmpty()) {
return null;
}
for (String key : map.keySet()) {
if (!KNOWN_KEYS.contains(key)) {
logger.warn("configure logging.mask: unknown key '{}' (known: {})", key, KNOWN_KEYS);
}
}
String replacement = map.get("replacement") instanceof String s ? s : DEFAULT_REPLACEMENT;
Set<String> headers = new LinkedHashSet<>();
if (map.get("headers") instanceof List<?> list) {
for (Object item : list) {
if (item != null) {
headers.add(item.toString().toLowerCase());
}
}
}
List<String> jsonPaths = new ArrayList<>();
if (map.get("jsonPaths") instanceof List<?> list) {
for (Object item : list) {
if (item != null) {
jsonPaths.add(item.toString());
}
}View on GitHub (pinned to a22eb90246)