{"record":{"id":"a21e239841c20320","repo":"languagetool-org/languagetool","slug":"could-not-find-day-of-week-for-daystr-a21e23","errorCode":null,"errorMessage":"Could not find day of week for '<dayStr>'","messagePattern":"Could not find day of week for '<dayStr>'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/ru/src/main/java/org/languagetool/rules/ru/DateFilterHelper.java","lineNumber":51,"sourceCode":"    return Calendar.getInstance(Locale.forLanguageTag(\"ru\"));\n  }\n\n  @SuppressWarnings(\"ControlFlowStatementWithoutBraces\")\n  protected int getDayOfWeek(String dayStr) {\n    String day = StringTools.trimSpecialCharacters(dayStr).toLowerCase();  // quickfix for special characters like soft hyphens\n    if (day.startsWith(\"суб\")) return Calendar.SATURDAY;\n    if (day.startsWith(\"вс\")) return Calendar.SUNDAY;\n    if (day.startsWith(\"вос\")) return Calendar.SUNDAY;\n    if (day.startsWith(\"пн\")) return Calendar.MONDAY;\n    if (day.startsWith(\"пон\")) return Calendar.MONDAY;\n    if (day.startsWith(\"вт\")) return Calendar.TUESDAY;\n    if (day.startsWith(\"ср\")) return Calendar.WEDNESDAY;\n    if (day.startsWith(\"чт\")) return Calendar.THURSDAY;\n    if (day.startsWith(\"чет\")) return Calendar.THURSDAY;\n    if (day.startsWith(\"пт\")) return Calendar.FRIDAY;\n    if (day.startsWith(\"пят\")) return Calendar.FRIDAY;\n    if (day.startsWith(\"сб\")) return Calendar.SATURDAY;\n    throw new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n  }\n\n  protected String getDayOfWeek(Calendar date) {\n    return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag(\"ru\"));\n  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  protected int getMonth(String monthStr) {\n    String mon = StringTools.trimSpecialCharacters(monthStr).toLowerCase();\n    if (mon.startsWith(\"янв\")) return 1;\n    if (mon.startsWith(\"фев\")) return 2;\n    if (mon.startsWith(\"мар\")) return 3;\n    if (mon.startsWith(\"апр\")) return 4;\n    if (mon.startsWith(\"май\")) return 5;\n    if (mon.startsWith(\"мая\")) return 5; //\n    if (mon.startsWith(\"июн\")) return 6;\n    if (mon.startsWith(\"июл\")) return 7;\n    if (mon.startsWith(\"авг\")) return 8;","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/ru/src/main/java/org/languagetool/rules/ru/DateFilterHelper.java#L33-L69","documentation":"DateFilterHelper.getDayOfWeek() maps Russian weekday tokens (пн, вт, ср, чт, пт, сб, вс and their full forms via startsWith) to Calendar constants. Unmatched tokens trigger this RuntimeException. It is the sibling of DateCheckFilter's version but with a narrower prefix list, so forms matched by rules but absent here crash.","triggerScenarios":"A date rule matched a weekday form whose prefix is not in the list — notably 'понедельник/пн' and full forms like 'четверг' are only partially covered ('чет' covers четверг but e.g. an inflected 'четвергом' would match; a form like 'втр' or 'сред' handled differently could fail). Any token failing all startsWith checks in DateFilterHelper.getDayOfWeek (DateFilterHelper.java:51) throws.","commonSituations":"Relative-date rules in the ru module fed by tokens the helper list does not anticipate; divergent maintenance between DateCheckFilter and DateFilterHelper day lists; new abbreviations added to regexes but not to this helper; user text with misspelled weekdays.","solutions":["Add the failing token's prefix to DateFilterHelper.getDayOfWeek (DateFilterHelper.java:51) and return the correct Calendar constant","Align this list with DateCheckFilter.getDayOfWeek so both cover the same forms (e.g. add 'пн'/понедельник and full-form branches present in the other class)","Restrict the matching regex rule to known weekday forms","Add a DateFilterHelperTest case for the token from the message"],"exampleFix":"// before\nif (day.startsWith(\"сб\")) return Calendar.SATURDAY;\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");\n// after\nif (day.startsWith(\"сб\") || day.startsWith(\"суббот\")) return Calendar.SATURDAY;\nif (day.startsWith(\"вс\") || day.startsWith(\"воскресень\")) return Calendar.SUNDAY;\nthrow new RuntimeException(\"Could not find day of week for '\" + dayStr + \"'\");","handlingStrategy":"validation","validationCode":"Set<String> ok = Set.of(\"пн\",\"вт\",\"ср\",\"чт\",\"чет\",\"пт\",\"пят\",\"сб\",\"суб\",\"вс\",\"воскрес\");\nboolean supported(String day) {\n  String d = day.toLowerCase(Locale.ROOT);\n  return ok.stream().anyMatch(d::startsWith);\n}\n// gate the filter call on supported(token)","typeGuard":"boolean isKnownWeekdayAbbrev(String token) {\n  String d = token.toLowerCase(Locale.ROOT);\n  return d.matches(\"(пн|вт|ср|чт|чет|пт|пят|сб|суб|вс|воскрес|понедель|вторник|сред|четверг|пятниц|суббот).*\");\n}","tryCatchPattern":"try {\n  analyzed = helper.filter(tokens, arguments);\n} catch (RuntimeException e) {\n  if (String.valueOf(e.getMessage()).contains(\"Could not find day of week\")) {\n    return Collections.emptyList(); // degrade gracefully for this match\n  }\n  throw e;\n}","preventionTips":["Mirror all weekday forms handled by DateCheckFilter into DateFilterHelper","Cover both abbreviations and full nominative/inflected forms with prefixes","Add regression tests whenever a new date regex is introduced","Log the offending token (already in the message) and extend the list before releasing"],"tags":["java","russian","nlp","date-parsing","languagetool"],"backgroundTag":"invalid-enum-value","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"}