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
YMDNewYearDateFilter validates date-rule arguments before processing. This date-check filter only supports the 'weekDay' and 'date' arguments; if a rule's XML passes 'year', 'month', or 'day' instead, the filter throws immediately in acceptRuleMatch to signal that the rule is configured for the wrong filter class (e.g. the general YMDDateCheckFilter).
Source
Thrown at languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/YMDNewYearDateFilter.java:39
import org.languagetool.AnalyzedTokenReadings;
import org.languagetool.rules.RuleMatch;
import org.languagetool.rules.YMDDateHelper;
import java.util.List;
import java.util.Map;
/**
* New year date filter that expects a 'date' argument in the format 'yyyy-mm-dd'.
* @since 4.3
*/
public class YMDNewYearDateFilter extends NewYearDateFilter {
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());
}
args = ymdDateHelper.parseDate(args);
return super.acceptRuleMatch(ymdDateHelper.correctDate(match, args), args, patternTokenPos, patternTokens, tokenPositions);
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Remove the 'year', 'month', and 'day' arguments from the rule's filter arguments, keeping only 'weekDay' and 'date'.
- If the rule needs year/month/day matching, switch the rule to use YMDDateCheckFilter instead of YMDNewYearDateFilter.
- Verify the referenced filter class name in the rule XML matches the argument set the filter supports.
Example fix
// before (rule args)
args.put("year", "no"); args.put("month", "12");
// after
args.put("weekDay", "weekDay"); args.put("date", "date"); Defensive patterns
Strategy: validation
Validate before calling
if (args.containsKey("year") || args.containsKey("month") || args.containsKey("day")) {
throw new IllegalArgumentException("YMDNewYearDateFilter accepts only 'weekDay' and 'date' args");
} Prevention
- Only pass 'weekDay' and 'date' args to YMDNewYearDateFilter rules
- Use YMDDateCheckFilter when year/month/day matching is needed
- Review rule XML filter args against the filter class documentation
When it happens
Trigger: A LanguageTool XML rule uses this filter but its <filter> args map contains any of the keys 'year', 'month', or 'day' instead of only 'weekDay' and 'date'.
Common situations: Copying a rule pattern from a date filter that accepts year/month/day and reusing it with YMDNewYearDateFilter; hand-editing rule XML and leaving stale year/month/day arguments; mixing up YMDDateCheckFilter and YMDNewYearDateFilter in rule definitions.
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
- Could not find day of week for '" + dayStr + "'
- Could not find month '" + monthStr + "'
- Set only 'weekDay' and 'date' for " + DMYDateCheckFilter.cla
- ConfusionCheckFilter: Index out of bounds in " + match.getRu
- ConfusionCheckFilter: Index out of bounds in " + match.getRu
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/981cd826b0f1db23.
Report an issue: GitHub.