{"record":{"id":"6376cf3edac96ada","repo":"languagetool-org/languagetool","slug":"could-not-find-month-monthstr-6376cf","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/es/src/main/java/org/languagetool/rules/es/DateFilterHelper.java","lineNumber":74,"sourceCode":"    return \"\";\n  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.startsWith(\"en\")) return 1;\n    if (mon.startsWith(\"fe\")) return 2;\n    if (mon.startsWith(\"mar\") || mon.startsWith(\"mzo\")) return 3;\n    if (mon.startsWith(\"ab\")) return 4;\n    if (mon.startsWith(\"may\") || mon.startsWith(\"my\")) return 5;\n    if (mon.startsWith(\"jun\") || mon.equals(\"jn\")) return 6;\n    if (mon.startsWith(\"jul\") || mon.equals(\"jl\")) return 7;\n    if (mon.startsWith(\"ag\")) return 8;\n    if (mon.startsWith(\"se\") || mon.startsWith(\"sep\")) return 9;\n    if (mon.startsWith(\"oc\")) return 10;\n    if (mon.startsWith(\"no\")) return 11;\n    if (mon.startsWith(\"di\")) return 12;\n    throw new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n  }\n}\n","sourceCodeStart":56,"sourceCodeEnd":77,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/es/src/main/java/org/languagetool/rules/es/DateFilterHelper.java#L56-L77","documentation":"DateFilterHelper.getMonth(String) maps Spanish month names/abbreviations to numbers 1-12 via prefix matching (enero, feb, mar, abr, may, jun, jul, ag..., se..., oc..., no..., di...). If the string starts with none of the known prefixes it throws RuntimeException.","triggerScenarios":"A Spanish date rule passes a month token like 'setiembre', 'deptiembre' (unusual spellings), an empty string, or a non-month token captured by the rule regex to getMonth(monthStr).","commonSituations":"Regional spellings ('setiembre' in some Latin American usage) that don't start with 'se'... actually 'se' matches setiembre — more often: typos, missing accents handled, or a regex capturing the wrong group; empty capture when the rule's month token is optional.","solutions":["Check the message's month string and either fix the rule regex so it captures a valid Spanish month, or add the spelling as a recognized prefix.","Normalize case/accents in the caller before invoking getMonth.","Ensure optional month tokens are only passed to the filter when actually matched."],"exampleFix":"// before\nif (mon.startsWith(\"se\") || mon.startsWith(\"sep\")) return 9;\n// after (adds regional spelling)\nif (mon.startsWith(\"se\") || mon.startsWith(\"set\")) return 9; // covers setiembre","handlingStrategy":"validation","validationCode":"String[] prefixes = {\"ene\",\"feb\",\"mar\",\"abr\",\"may\",\"jun\",\"jul\",\"ag\",\"se\",\"oc\",\"no\",\"di\"};\nString mon = monthStr.toLowerCase();\nif (Arrays.stream(prefixes).noneMatch(mon::startsWith)) throw new IllegalArgumentException(\"Unsupported month: \" + monthStr);","typeGuard":null,"tryCatchPattern":"try {\n  int month = helper.getMonth(monthStr);\n} catch (RuntimeException e) {\n  LOG.warn(\"Unrecognized month token '{}' — skipping date check\", monthStr);\n}","preventionTips":["Normalize case/accents before month lookup","Only pass month tokens actually captured by the rule regex","Test with regional month spellings (e.g. 'setiembre')"],"tags":["java","languagetool","date-parsing","spanish"],"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"}