languagetool-org/languagetool · error · RuntimeException
Could not find month '" + monthStr + "'
Error message
Could not find month '" + monthStr + "'
What it means
DateFilterHelper.getMonth maps French month names/abbreviations to Calendar month numbers via startsWith prefixes (jan..déc/dec). This RuntimeException is thrown when the month string matches none of the prefixes, so a date rule cannot resolve its month argument.
Source
Thrown at languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DateFilterHelper.java:71
String mon = monthStr.toLowerCase();
if (mon.startsWith("jan")) return 1;
if (mon.startsWith("fév")) return 2;
if (mon.startsWith("fev")) return 2;
if (mon.startsWith("mar")) return 3;
if (mon.startsWith("avr")) return 4;
if (mon.startsWith("mai")) return 5;
// "juin" and "juillet" are never abbreviated with 3 letters
// since it would be ambiguous (both start with "jui").
if (mon.startsWith("juin")) return 6;
if (mon.startsWith("juil")) return 7;
if (mon.startsWith("aou") ||
mon.startsWith("aoû")) return 8;
if (mon.startsWith("sep")) return 9;
if (mon.startsWith("oct")) return 10;
if (mon.startsWith("nov")) return 11;
if (mon.startsWith("déc")) return 12;
if (mon.startsWith("dec")) return 12;
throw new RuntimeException("Could not find month '" + monthStr + "'");
}
}
View on GitHub (pinned to 2e990059ce)
Solutions
- Supply a French month name or standard abbreviation (janvier, févr., août, déc., ...) in the rule argument.
- Add a numeric branch at the top of getMonth for 1..12 inputs.
- Verify file/arg encoding is UTF-8 so accented prefixes (fév, aoû, déc) match correctly.
Example fix
// before
throw new RuntimeException("Could not find month '" + monthStr + "'");
// after
try {
int n = Integer.parseInt(mon);
if (n >= 1 && n <= 12) return n;
} catch (NumberFormatException ignore) {}
throw new RuntimeException("Could not find month '" + monthStr + "'"); Defensive patterns
Strategy: validation
Validate before calling
Set<String> prefixes = Set.of("jan","fév","fev","mar","avr","mai","juin","juil","aoû","aou","sep","oct","nov","déc","dec");
String m = monthStr == null ? "" : monthStr.toLowerCase().trim();
if (prefixes.stream().noneMatch(m::startsWith)) {
throw new IllegalArgumentException("Unsupported month: " + monthStr);
} Try / catch
try { int month = helper.getMonth(cal); } catch (RuntimeException e) { LOG.warn("Unmapped month: " + e.getMessage()); } Prevention
- Pass French month names/abbreviations, never numbers or English names.
- Ensure UTF-8 encoding for accented prefixes (fév, aoû, déc).
- Consider adding a numeric-month branch to getMonth.
When it happens
Trigger: getMonthFromArguments passes a 'month' argument whose lowercase value does not start with jan/fév|fev/mar/avr|avr/mai/juin|juin/juil|juil/aoû|aou/sep/oct/nov/déc|dec — e.g. numeric months ('08'), English names ('august'), misspellings, or accents stripped in a way not covered ('aou' is handled, but other variants may not be).
Common situations: Rules authored with numeric month values; input from other locales; encoding problems turning 'aoû'/'déc' into 'août'/'dÃ(c)c' so the prefix no longer matches.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Could not find day of week for '" + dayStr + "'
- Could not find day of week for '" + dayStr + "'
- Could not find month '" + monthStr + "'
- Set only 'weekDay' and 'date' for " + DMYDateCheckFilter.cla
- Expected date in format 'dd-mm-yyyy': '" + dateString + "'
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/b7d6339919ffec24.
Report an issue: GitHub.