{"record":{"id":"ca2fa14093e1791b","repo":"languagetool-org/languagetool","slug":"could-not-find-month-monthstr-ca2fa1","errorCode":null,"errorMessage":"Could not find month '<monthStr>'","messagePattern":"Could not find month '<monthStr>'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/DateCheckFilter.java","lineNumber":70,"sourceCode":"    return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag(\"uk\"));\n  }\n\n  @Override\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.startsWith(\"сі\")) return Calendar.JANUARY + 1;\n    if (mon.startsWith(\"лю\")) return Calendar.FEBRUARY + 1;\n    if (mon.startsWith(\"бе\")) return Calendar.MARCH + 1;\n    if (mon.startsWith(\"кв\")) return Calendar.APRIL + 1;\n    if (mon.startsWith(\"тр\")) return Calendar.MAY + 1;\n    if (mon.startsWith(\"че\")) return Calendar.JUNE + 1;\n    if (mon.startsWith(\"ли\")) return Calendar.JULY + 1;\n    if (mon.startsWith(\"се\")) return Calendar.AUGUST + 1;\n    if (mon.startsWith(\"ве\")) return Calendar.SEPTEMBER + 1;\n    if (mon.startsWith(\"жо\")) return Calendar.OCTOBER + 1;\n    if (mon.startsWith(\"ли\")) return Calendar.NOVEMBER + 1;\n    if (mon.startsWith(\"гр\")) return Calendar.DECEMBER + 1;\n    throw new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n  }\n\n}\n","sourceCodeStart":52,"sourceCodeEnd":74,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/DateCheckFilter.java#L52-L74","documentation":"DateCheckFilter for Ukrainian maps a month token (Ukrainian month-name prefix) to a month number derived from Calendar constants (+1). If the token matches none of the recognized prefixes, getMonth throws this RuntimeException indicating an unrecognized Ukrainian month string. Note the source's Calendar.X + 1 pattern assumes Calendar.JANUARY == 0.","triggerScenarios":"Passing a month string that does not start with any accepted Ukrainian prefix (сі/лю/бе/кв/тр/че/ли/се/ве/жо/гр) — e.g. a Russian month ('января'), an English month, an abbreviation ('січ'), or a mis-cased string — into getMonth.","commonSituations":"Mixed Ukrainian/Russian text where Russian month names reach the Ukrainian filter; abbreviations matched by a rule but unsupported by the prefix checks; typos in custom grammar rules.","solutions":["Verify the month string is a full Ukrainian month name (січень…грудень) so its prefix matches.","Normalize case and trim whitespace before calling the filter.","Add support for abbreviations/inflected forms in getMonth if your rules produce them.","Reject or reroute non-Ukrainian month tokens before invoking DateCheckFilter."],"exampleFix":"// before: unguarded call throws on unmatched token\nint month = filter.getMonth(monthStr);\n// after: pre-validate with accepted prefixes\nString mon = monthStr.trim().toLowerCase(Locale.forLanguageTag(\"uk\"));\nList<String> prefixes = List.of(\"сі\",\"лю\",\"бе\",\"кв\",\"тр\",\"че\",\"ли\",\"се\",\"ве\",\"жо\",\"гр\");\nif (prefixes.stream().noneMatch(mon::startsWith)) {\n  throw new IllegalArgumentException(\"Unrecognized Ukrainian month: \" + monthStr);\n}","handlingStrategy":"validation","validationCode":"private static final List<String> UK_MONTH_PREFIXES = List.of(\"сі\",\"лю\",\"бе\",\"кв\",\"тр\",\"че\",\"ли\",\"се\",\"ве\",\"жо\",\"гр\");\nboolean isRecognizedUkrainianMonth(String monthStr) {\n  String m = monthStr == null ? \"\" : monthStr.trim().toLowerCase(Locale.forLanguageTag(\"uk\"));\n  return UK_MONTH_PREFIXES.stream().anyMatch(m::startsWith);\n}","typeGuard":null,"tryCatchPattern":"try {\n  int month = filter.getMonth(monthStr);\n} catch (RuntimeException e) {\n  logger.warn(\"Unrecognized Ukrainian month token: {}\", monthStr);\n  // treat date as invalid / skip suggestion\n}","preventionTips":["Normalize case and trim before calling the filter.","Guard against Russian month names in mixed-language text.","Add unit tests for all 12 Ukrainian month names and any inflected forms your rules emit."],"tags":["java","ukrainian","date-parsing","languagetool"],"backgroundTag":"invalid-date-format","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"}