languagetool-org/languagetool · error · RuntimeException

Could not find month '" + monthStr + "'

Error message

Could not find month '" + monthStr + "'

What it means

The Esperanto DateCheckFilter maps Esperanto month-name prefixes ('jan'..'dec', including x- and h-transliterations) to month numbers. getMonth throws a RuntimeException when the month string does not start with any recognized Esperanto month prefix.

Source

Thrown at languagetool-language-modules/eo/src/main/java/org/languagetool/rules/eo/DateCheckFilter.java:121

  }

  @SuppressWarnings({"ControlFlowStatementWithoutBraces", "MagicNumber"})
  @Override
  protected int getMonth(String monthStr) {
    String mon = monthStr.toLowerCase();
    if (mon.startsWith("jan")) return 1;
    if (mon.startsWith("feb")) return 2;
    if (mon.startsWith("mar")) return 3;
    if (mon.startsWith("apr")) return 4;
    if (mon.startsWith("maj")) return 5;
    if (mon.startsWith("jun")) return 6;
    if (mon.startsWith("jul")) return 7;
    if (mon.startsWith("aŭg")) return 8;
    if (mon.startsWith("sep")) return 9;
    if (mon.startsWith("okt")) return 10;
    if (mon.startsWith("nov")) return 11;
    if (mon.startsWith("dec")) return 12;
    throw new RuntimeException("Could not find month '" + monthStr + "'");
  }
}

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Check the month string for typos and ensure it is a real Esperanto month name.
  2. If a valid spelling variant is missing, extend getMonth with the corresponding startsWith case.
  3. Constrain the rule pattern so only month tokens are passed to the filter.

Example fix

// before
getMonth("januaro"); // works, prefix 'jan'
getMonth("Mero"); // throws
// after
getMonth("mar"); // returns 3
Defensive patterns

Strategy: validation

Validate before calling

List<String> prefixes = List.of("jan","feb","mar","apr","maj","jun","jul","aŭg","aug","sep","okt","nov","dec");
String mon = monthStr.toLowerCase();
if (prefixes.stream().noneMatch(mon::startsWith)) throw new IllegalArgumentException("Not an Esperanto month: " + monthStr);

Try / catch

try {
  int month = filter.getMonth(monthStr);
} catch (RuntimeException e) {
  if (e.getMessage().startsWith("Could not find month")) { /* skip or log invalid month token */ }
}

Prevention

When it happens

Trigger: A date-check rule passes a 'month' token whose lowercase text does not begin with a recognized Esperanto month prefix (jan, feb, mar, maj, jun, jul, aŭg/aug/jul variants, sep, okt, nov, dec).

Common situations: Rule patterns that capture non-month tokens; misspelled months; transliteration variants (aug/agŭ, dec) not covered; tests exercising unknown month strings.

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


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/0261ad620faafc11. Report an issue: GitHub.