languagetool-org/languagetool · error · RuntimeException

Missing 'antiPatterns:' in 'args' in <filter> of rule ${matc

Error message

Missing 'antiPatterns:' in 'args' in <filter> of rule ${match.getRule().getFullId()}

What it means

Sentinel guard in a rule filter: the <filter> element of the XML rule declared class RegexAntiPatternFilter but its arguments contain no 'antiPatterns' entry, so the filter has no patterns to test against and cannot decide whether to drop the match. The faulty input is the filter's argument string in the rule XML.

Source

Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexAntiPatternFilter.java:41

import org.languagetool.rules.RuleMatch;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Filters matches that match a regex. Limitations: 1. antipatterns cannot contain spaces,
 * 2. The pipe (|) is used to delimit several patterns and cannot be used inside a pattern.
 * @since 5.2
 */
public class RegexAntiPatternFilter extends RegexRuleFilter {

  @Nullable
  @Override
  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, AnalyzedSentence sentenceObj, Matcher patternMatcher) {
    String antiPatternStr = arguments.get("antipatterns");
    if (antiPatternStr == null) {
      throw new RuntimeException("Missing 'antiPatterns:' in 'args' in <filter> of rule " + match.getRule().getFullId());
    }
    String[] antiPatterns = antiPatternStr.split("\\|");
    for (String antiPattern : antiPatterns) {
      Pattern p = Pattern.compile(antiPattern);
      Matcher matcher = p.matcher(sentenceObj.getText());
      while (matcher.find()) {
        // partial overlap is enough to filter out a match:
        if (matcher.start() <= match.getToPos() && matcher.end() >= match.getToPos() ||
            matcher.start() <= match.getFromPos() && matcher.end() >= match.getFromPos()) {
          return null;
        }
      }
    }
    return match;
  }
}

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Add an antiPatterns argument to the <filter> element, e.g. <filter class="org.languagetool.rules.patterns.RegexAntiPatternFilter" args="antiPatterns:foo|bar"/>
  2. Check for typos in the argument key: it must be spelled exactly 'antiPatterns'
  3. If no anti-pattern filtering is needed, remove the filter element from the rule
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexAntiPatternFilter.java:41 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/c66e33b5c5684b0e. Report an issue: GitHub.