languagetool-org/languagetool · error · RuntimeException
Set only 'weekDay' and 'date' for " + YMDDateCheckFilter.cla
Error message
Set only 'weekDay' and 'date' for " + YMDDateCheckFilter.class.getSimpleName()
What it means
YMDDateCheckFilter.acceptRuleMatch validates which parameters a regex/date rule may set. This filter only supports the 'weekDay' and 'date' arguments; if the rule XML passes 'year', 'month' or 'day' (which belong to other date filters), it throws a RuntimeException naming the filter class.
Source
Thrown at languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/YMDDateCheckFilter.java:39
import org.languagetool.AnalyzedTokenReadings;
import org.languagetool.rules.RuleMatch;
import org.languagetool.rules.YMDDateHelper;
import java.util.List;
import java.util.Map;
/**
* Date filter that expects a 'date' argument in the format 'yyyy-mm-dd'.
* @since 3.2
*/
public class YMDDateCheckFilter extends DateCheckFilter {
private final YMDDateHelper ymdDateHelper = new YMDDateHelper();
@Override
public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) {
if (args.containsKey("year") || args.containsKey("month") || args.containsKey("day")) {
throw new RuntimeException("Set only 'weekDay' and 'date' for " + YMDDateCheckFilter.class.getSimpleName());
}
return super.acceptRuleMatch(match, ymdDateHelper.parseDate(args), patternTokenPos, patternTokens, tokenPositions);
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Remove year/month/day from the rule's filter args, keeping only weekDay and/or date
- If the rule needs year/month/day matching, use the date filter class designed for those arguments
- Re-run the rule against a test sentence after editing the XML
Example fix
<!-- before --> <filter class="org.languagetool.rules.en.YMDDateCheckFilter" args="date:\d year:(\d+) month:(\d+) day:(\d+)"/> <!-- after --> <filter class="org.languagetool.rules.en.YMDDateCheckFilter" args="date:\d weekDay:MONDAY|TUESDAY"/>
Defensive patterns
Strategy: validation
Validate before calling
// validate rule XML filter args before loading rules
Set<String> allowed = Set.of("weekDay", "date");
Map<String,String> args = parseFilterArgs(xmlFilterArgs);
args.keySet().retainAll(Set.of("year","month","day","weekDay","date"));
if (args.keySet().stream().anyMatch(k -> !allowed.contains(k))) {
throw new IllegalStateException("YMDDateCheckFilter accepts only weekDay/date");
} Try / catch
try {
rule = language.getRuleById("EN_YMD_DATE", sentence);
tool.check(sentence);
} catch (RuntimeException e) {
if (e.getMessage().contains("Set only 'weekDay' and 'date'")) {
log.error("rule XML uses unsupported filter args: " + e.getMessage());
} else throw e;
} Prevention
- Only use weekDay/date with YMDDateCheckFilter; year/month/day belong to other filters
- Lint rule XML filter args against each filter class's accepted keys
- Test each new/edited date rule with a sample sentence before committing
When it happens
Trigger: A Grammar/regex rule XML uses <filter class="...YMDDateCheckFilter" args="..."/> but includes year=, month= or day= in its filter arguments, e.g. copied from a DMYDateCheckFilter-style rule.
Common situations: Copy-pasting filter args between date-check rule variants; writing a new English date rule and mixing filter argument conventions; renaming/merging date rules without updating args.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- 'skip' should be between -1 and ${Byte.MAX_VALUE}
- minOccurrences must be 0 or 1: ${i}
- maxOccurrences may not be 0
- maxOccurrences should be between -1 and ${Byte.MAX_VALUE} bu
- minOccurrence must be >= 0: ${minOccurrence}
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/48a54c89f951ea0f.
Report an issue: GitHub.