{"record":{"id":"c66e33b5c5684b0e","repo":"languagetool-org/languagetool","slug":"missing-antipatterns-in-args-in-filter-of-r","errorCode":null,"errorMessage":"Missing 'antiPatterns:' in 'args' in <filter> of rule ${match.getRule().getFullId()}","messagePattern":"Missing 'antiPatterns:' in 'args' in <filter> of rule (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexAntiPatternFilter.java","lineNumber":41,"sourceCode":"import org.languagetool.rules.RuleMatch;\n\nimport java.util.Map;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\n\n/**\n * Filters matches that match a regex. Limitations: 1. antipatterns cannot contain spaces,\n * 2. The pipe (|) is used to delimit several patterns and cannot be used inside a pattern.\n * @since 5.2\n */\npublic class RegexAntiPatternFilter extends RegexRuleFilter {\n\n  @Nullable\n  @Override\n  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> arguments, AnalyzedSentence sentenceObj, Matcher patternMatcher) {\n    String antiPatternStr = arguments.get(\"antipatterns\");\n    if (antiPatternStr == null) {\n      throw new RuntimeException(\"Missing 'antiPatterns:' in 'args' in <filter> of rule \" + match.getRule().getFullId());\n    }\n    String[] antiPatterns = antiPatternStr.split(\"\\\\|\");\n    for (String antiPattern : antiPatterns) {\n      Pattern p = Pattern.compile(antiPattern);\n      Matcher matcher = p.matcher(sentenceObj.getText());\n      while (matcher.find()) {\n        // partial overlap is enough to filter out a match:\n        if (matcher.start() <= match.getToPos() && matcher.end() >= match.getToPos() ||\n            matcher.start() <= match.getFromPos() && matcher.end() >= match.getFromPos()) {\n          return null;\n        }\n      }\n    }\n    return match;\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":58,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexAntiPatternFilter.java#L23-L58","documentation":"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.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/rules/patterns/RegexAntiPatternFilter.java:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add an antiPatterns argument to the <filter> element, e.g. <filter class=\"org.languagetool.rules.patterns.RegexAntiPatternFilter\" args=\"antiPatterns:foo|bar\"/>","Check for typos in the argument key: it must be spelled exactly 'antiPatterns'","If no anti-pattern filtering is needed, remove the filter element from the rule"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}