{"record":{"id":"0eb9f67da90d8d1e","repo":"languagetool-org/languagetool","slug":"could-not-find-month-monthstr-0eb9f6","errorCode":null,"errorMessage":"Could not find month '<monthStr>'","messagePattern":"Could not find month '<monthStr>'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/it/src/main/java/org/languagetool/rules/it/DateCheckFilter.java","lineNumber":81,"sourceCode":"  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  @Override\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.startsWith(\"gen\")) return 1;\n    if (mon.startsWith(\"feb\")) return 2;\n    if (mon.startsWith(\"mar\")) return 3;\n    if (mon.startsWith(\"apr\")) return 4;\n    if (mon.startsWith(\"mag\")) return 5;\n    if (mon.startsWith(\"giu\")) return 6;\n    if (mon.startsWith(\"lug\")) return 7;\n    if (mon.startsWith(\"ago\")) return 8;\n    if (mon.startsWith(\"set\")) return 9;\n    if (mon.startsWith(\"ott\")) return 10;\n    if (mon.startsWith(\"nov\")) return 11;\n    if (mon.startsWith(\"dic\")) return 12;\n    throw new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n  }\n}\n","sourceCodeStart":63,"sourceCodeEnd":84,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/it/src/main/java/org/languagetool/rules/it/DateCheckFilter.java#L63-L84","documentation":"The Italian DateCheckFilter maps Italian month names/abbreviations to month numbers in getMonth. It throws this RuntimeException when the input string matches none of the known prefixes (gen, feb, mar, apr, mag, giu, lug, ago, set, ott, nov, dic). It signals that the month token produced by the calling rule is not in the filter's recognized vocabulary.","triggerScenarios":"A rule passes a month string that does not start with one of the recognized Italian month prefixes (e.g. an English month 'mar' colliding is fine, but 'may', 'maggio' misspelled, or a Roman numeral like 'VII' which getMonth does not accept).","commonSituations":"Date rule regex extended to accept new month forms (Roman numerals, full genitive forms) without updating getMonth; locale-specific abbreviations differing from the hardcoded prefixes.","solutions":["Add or correct the missing month mapping in getMonth for the string shown in the message","Normalize the input (lowercase, trim) before the prefix checks if the caller may pass mixed-case text","Align the rule's regex alternation with exactly the prefixes handled in getMonth"],"exampleFix":"// before\nif (mon.startsWith(\"dic\")) return 12;\nthrow new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n// after\nif (mon.startsWith(\"dic\")) return 12;\nthrow new RuntimeException(\"Could not find month '\" + monthStr + \"'\"); // ensure caller only passes recognized prefixes; e.g. normalize first\n// or: if (mon.startsWith(\"gen\")) return 1; // add missing month","handlingStrategy":"validation","validationCode":"Set<String> prefixes = Set.of(\"gen\",\"feb\",\"mar\",\"apr\",\"mag\",\"giu\",\"lug\",\"ago\",\"set\",\"ott\",\"nov\",\"dic\");\nif (!prefixes.stream().anyMatch(monthStr.toLowerCase()::startsWith)) throw new IllegalArgumentException(\"Unrecognized Italian month: \" + monthStr);","typeGuard":"boolean isItalianMonth(String s) { String m = s == null ? \"\" : s.toLowerCase(); return m.length() >= 3 && Set.of(\"gen\",\"feb\",\"mar\",\"apr\",\"mag\",\"giu\",\"lug\",\"ago\",\"set\",\"ott\",\"nov\",\"dic\").stream().anyMatch(m::startsWith); }","tryCatchPattern":"try { month = filter.getMonth(monthStr); } catch (RuntimeException e) { log.warn(\"Unknown month token: {}\", monthStr); return null; }","preventionTips":["Write a parametrized test covering all Italian month forms your rule regex accepts","Lowercase and trim input before prefix matching","Document that Roman numerals are not accepted by getMonth"],"tags":["java","nlp","grammar-rules","date-validation"],"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"}