{"record":{"id":"981cd826b0f1db23","repo":"languagetool-org/languagetool","slug":"set-only-weekday-and-date-for-ymddatecheck-981cd8","errorCode":null,"errorMessage":"Set only 'weekDay' and 'date' for \" + YMDDateCheckFilter.class.getSimpleName()","messagePattern":"Set only 'weekDay' and 'date' for \" \\+ YMDDateCheckFilter\\.class\\.getSimpleName\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/YMDNewYearDateFilter.java","lineNumber":39,"sourceCode":"import org.languagetool.AnalyzedTokenReadings;\nimport org.languagetool.rules.RuleMatch;\nimport org.languagetool.rules.YMDDateHelper;\n\nimport java.util.List;\nimport java.util.Map;\n\n/**\n * New year date filter that expects a 'date' argument in the format 'yyyy-mm-dd'.\n * @since 4.3\n */\npublic class YMDNewYearDateFilter extends NewYearDateFilter {\n\n  private final YMDDateHelper ymdDateHelper = new YMDDateHelper();\n\n  @Override\n  public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> args, int patternTokenPos, AnalyzedTokenReadings[] patternTokens, List<Integer> tokenPositions) {\n    if (args.containsKey(\"year\") || args.containsKey(\"month\") || args.containsKey(\"day\")) {\n      throw new RuntimeException(\"Set only 'weekDay' and 'date' for \" + YMDDateCheckFilter.class.getSimpleName());\n    }\n    args = ymdDateHelper.parseDate(args);\n    return super.acceptRuleMatch(ymdDateHelper.correctDate(match, args), args, patternTokenPos, patternTokens, tokenPositions);\n  }\n\n}\n","sourceCodeStart":21,"sourceCodeEnd":46,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/en/src/main/java/org/languagetool/rules/en/YMDNewYearDateFilter.java#L21-L46","documentation":"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).","triggerScenarios":"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'.","commonSituations":"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.","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."],"exampleFix":"// before (rule args)\nargs.put(\"year\", \"no\"); args.put(\"month\", \"12\");\n// after\nargs.put(\"weekDay\", \"weekDay\"); args.put(\"date\", \"date\");","handlingStrategy":"validation","validationCode":"if (args.containsKey(\"year\") || args.containsKey(\"month\") || args.containsKey(\"day\")) {\n  throw new IllegalArgumentException(\"YMDNewYearDateFilter accepts only 'weekDay' and 'date' args\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["languagetool","rule-configuration","date-filter","invalid-argument"],"backgroundTag":"invalid-config-value","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}