languagetool-org/languagetool · error · IllegalArgumentException
suppressMisspelledSuggestions must be a valid regex
Error message
suppressMisspelledSuggestions must be a valid regex
What it means
Same family as error 56 but for the optional RemoteRule option 'suppressMisspelledSuggestions': the constructor compiles its value into a Pattern, and an invalid regex is rethrown as IllegalArgumentException with this message.
Source
Thrown at languagetool-core/src/main/java/org/languagetool/rules/RemoteRule.java:100
boolean includedInHiddenMatches = Boolean.parseBoolean(serviceConfiguration.getOptions().getOrDefault("includedInHiddenMatches", "true"));
setIncludedInHiddenMatches(includedInHiddenMatches);
try {
if (serviceConfiguration.getOptions().containsKey("suppressMisspelledMatch")) {
suppressMisspelledMatch = Pattern.compile(serviceConfiguration.getOptions().get("suppressMisspelledMatch"));
} else {
suppressMisspelledMatch = null;
}
} catch(PatternSyntaxException e) {
throw new IllegalArgumentException("suppressMisspelledMatch must be a valid regex", e);
}
try {
if (serviceConfiguration.getOptions().containsKey("suppressMisspelledSuggestions")) {
suppressMisspelledSuggestions = Pattern.compile(serviceConfiguration.getOptions().get("suppressMisspelledSuggestions"));
} else {
suppressMisspelledSuggestions = null;
}
} catch(PatternSyntaxException e) {
throw new IllegalArgumentException("suppressMisspelledSuggestions must be a valid regex", e);
}
}
public RemoteRule(Language language, ResourceBundle messages, RemoteRuleConfig config, boolean inputLogging) {
this(language, messages, config, inputLogging, null);
}
public static void shutdown() {
shutdownRoutines.forEach(Runnable::run);
}
public FutureTask<RemoteRuleResult> run(List<AnalyzedSentence> sentences) {
return run(sentences, null);
}
protected static class RemoteRequest {}
/**View on GitHub (pinned to 2e990059ce)
Solutions
- Correct the suppressMisspelledSuggestions option value so it compiles as a Java regex.
- Validate the pattern with Pattern.compile before loading config.
- Drop the option if it's not needed — it's optional.
- Double-check backslash escaping in the config file format.
Example fix
// before suppressMisspelledSuggestions=[misspelled // after suppressMisspelledSuggestions=(misspelled|mistyped)
Defensive patterns
Strategy: try-catch
Validate before calling
String opt = serviceConfig.getOptions().get("suppressMisspelledSuggestions");
if (opt != null) {
try { java.util.regex.Pattern.compile(opt); }
catch (java.util.regex.PatternSyntaxException e) {
throw new IllegalArgumentException("suppressMisspelledSuggestions is not valid regex: " + e.getMessage());
}
} Try / catch
try {
rule = new RemoteRule(language, messages, config, inputLogging);
} catch (IllegalArgumentException e) {
LOG.error("Bad suppressMisspelledSuggestions regex: {}", e.getMessage());
throw e;
} Prevention
- Keep both suppress* options in one validation helper
- Use a Java-flavored regex validator, not PCRE/grep tools
- Double-escape backslashes when the value passes through JSON
When it happens
Trigger: Setting RemoteRuleConfig option suppressMisspelledSuggestions to a string that Pattern.compile() rejects (syntax error such as unmatched '[', trailing '\', or '+' with no operand).
Common situations: Copy-pasting grep-flavored regex into Java config, mis-escaping in properties/JSON layers, or generating the option value dynamically from user input without validation.
Related errors
- suppressMisspelledMatch must be a valid regex
- Got " + matcher.groupCount() + " groups for regex '" + patte
- Got " + matcher.groupCount() + " groups for regex '" + patte
- Missing key '${key}'
- Format error in file ${path}, line: ${line}
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/231fdfdd2abb9c59.
Report an issue: GitHub.