{"record":{"id":"b7d6339919ffec24","repo":"languagetool-org/languagetool","slug":"could-not-find-month-monthstr-b7d633","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/fr/src/main/java/org/languagetool/rules/fr/DateFilterHelper.java","lineNumber":71,"sourceCode":"    String mon = monthStr.toLowerCase();\n    if (mon.startsWith(\"jan\")) return 1;\n    if (mon.startsWith(\"fév\")) return 2;\n    if (mon.startsWith(\"fev\")) return 2;\n    if (mon.startsWith(\"mar\")) return 3;\n    if (mon.startsWith(\"avr\")) return 4;\n    if (mon.startsWith(\"mai\")) return 5;\n    // \"juin\" and \"juillet\" are never abbreviated with 3 letters\n    // since it would be ambiguous (both start with \"jui\").\n    if (mon.startsWith(\"juin\")) return 6;\n    if (mon.startsWith(\"juil\")) return 7;\n    if (mon.startsWith(\"aou\") ||\n        mon.startsWith(\"aoû\")) return 8;\n    if (mon.startsWith(\"sep\")) return 9;\n    if (mon.startsWith(\"oct\")) return 10;\n    if (mon.startsWith(\"nov\")) return 11;\n    if (mon.startsWith(\"déc\")) return 12;\n    if (mon.startsWith(\"dec\")) return 12;\n    throw new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n  }\n}\n","sourceCodeStart":53,"sourceCodeEnd":74,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/fr/src/main/java/org/languagetool/rules/fr/DateFilterHelper.java#L53-L74","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nthrow new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n// after\ntry {\n  int n = Integer.parseInt(mon);\n  if (n >= 1 && n <= 12) return n;\n} catch (NumberFormatException ignore) {}\nthrow new RuntimeException(\"Could not find month '\" + monthStr + \"'\");","handlingStrategy":"validation","validationCode":"Set<String> prefixes = Set.of(\"jan\",\"fév\",\"fev\",\"mar\",\"avr\",\"mai\",\"juin\",\"juil\",\"aoû\",\"aou\",\"sep\",\"oct\",\"nov\",\"déc\",\"dec\");\nString m = monthStr == null ? \"\" : monthStr.toLowerCase().trim();\nif (prefixes.stream().noneMatch(m::startsWith)) {\n    throw new IllegalArgumentException(\"Unsupported month: \" + monthStr);\n}","typeGuard":null,"tryCatchPattern":"try { int month = helper.getMonth(cal); } catch (RuntimeException e) { LOG.warn(\"Unmapped month: \" + e.getMessage()); }","preventionTips":["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."],"tags":["java","languagetool","french","date-parsing"],"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"}