languagetool-org/languagetool · error · RuntimeException
Could not find month '<monthStr>'
Error message
Could not find month '<monthStr>'
What it means
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.
Source
Thrown at languagetool-language-modules/uk/src/main/java/org/languagetool/rules/uk/DateCheckFilter.java:70
return date.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.forLanguageTag("uk"));
}
@Override
protected int getMonth(String monthStr) {
String mon = monthStr.toLowerCase();
if (mon.startsWith("сі")) return Calendar.JANUARY + 1;
if (mon.startsWith("лю")) return Calendar.FEBRUARY + 1;
if (mon.startsWith("бе")) return Calendar.MARCH + 1;
if (mon.startsWith("кв")) return Calendar.APRIL + 1;
if (mon.startsWith("тр")) return Calendar.MAY + 1;
if (mon.startsWith("че")) return Calendar.JUNE + 1;
if (mon.startsWith("ли")) return Calendar.JULY + 1;
if (mon.startsWith("се")) return Calendar.AUGUST + 1;
if (mon.startsWith("ве")) return Calendar.SEPTEMBER + 1;
if (mon.startsWith("жо")) return Calendar.OCTOBER + 1;
if (mon.startsWith("ли")) return Calendar.NOVEMBER + 1;
if (mon.startsWith("гр")) return Calendar.DECEMBER + 1;
throw new RuntimeException("Could not find month '" + monthStr + "'");
}
}
View on GitHub (pinned to 2e990059ce)
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.
Example fix
// before: unguarded call throws on unmatched token
int month = filter.getMonth(monthStr);
// after: pre-validate with accepted prefixes
String mon = monthStr.trim().toLowerCase(Locale.forLanguageTag("uk"));
List<String> prefixes = List.of("сі","лю","бе","кв","тр","че","ли","се","ве","жо","гр");
if (prefixes.stream().noneMatch(mon::startsWith)) {
throw new IllegalArgumentException("Unrecognized Ukrainian month: " + monthStr);
} Defensive patterns
Strategy: validation
Validate before calling
private static final List<String> UK_MONTH_PREFIXES = List.of("сі","лю","бе","кв","тр","че","ли","се","ве","жо","гр");
boolean isRecognizedUkrainianMonth(String monthStr) {
String m = monthStr == null ? "" : monthStr.trim().toLowerCase(Locale.forLanguageTag("uk"));
return UK_MONTH_PREFIXES.stream().anyMatch(m::startsWith);
} Try / catch
try {
int month = filter.getMonth(monthStr);
} catch (RuntimeException e) {
logger.warn("Unrecognized Ukrainian month token: {}", monthStr);
// treat date as invalid / skip suggestion
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not find day of week for '<dayStr>'
- Could not find day of week for '" + dayStr + "'
- Could not find month '" + monthStr + "'
- Could not find day of week for '" + dayStr + "'
- Could not find month '" + monthStr + "'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/ca2fa14093e1791b.
Report an issue: GitHub.