{"record":{"id":"9bdcd9ec2b345db2","repo":"languagetool-org/languagetool","slug":"could-not-find-month-monthstr-9bdcd9","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/pl/src/main/java/org/languagetool/rules/pl/DateCheckFilter.java","lineNumber":70,"sourceCode":"  }\n\n  @SuppressWarnings({\"ControlFlowStatementWithoutBraces\", \"MagicNumber\"})\n  @Override\n  protected int getMonth(String monthStr) {\n    String mon = monthStr.toLowerCase();\n    if (mon.equals(\"stycznia\") || monthStr.equals(\"I\")) return 1;\n    if (mon.equals(\"lutego\") || monthStr.equals(\"II\")) return 2;\n    if (mon.equals(\"marca\") || monthStr.equals(\"III\")) return 3;\n    if (mon.equals(\"kwietnia\") || monthStr.equals(\"IV\")) return 4;\n    if (mon.equals(\"maja\") || monthStr.equals(\"V\")) return 5;\n    if (mon.equals(\"czerwca\") || monthStr.equals(\"VI\")) return 6;\n    if (mon.equals(\"lipca\") || monthStr.equals(\"VII\")) return 7;\n    if (mon.equals(\"sierpnia\") || monthStr.equals(\"VIII\")) return 8;\n    if (mon.equals(\"września\") || monthStr.equals(\"IX\")) return 9;\n    if (mon.equals(\"października\") || monthStr.equals(\"X\")) return 10;\n    if (mon.equals(\"listopada\") || monthStr.equals(\"XI\")) return 11;\n    if (mon.equals(\"grudnia\") || monthStr.equals(\"XII\")) return 12;\n    throw new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n  }\n}\n","sourceCodeStart":52,"sourceCodeEnd":73,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/pl/src/main/java/org/languagetool/rules/pl/DateCheckFilter.java#L52-L73","documentation":"The Polish DateCheckFilter's getMonth accepts only exact genitive month names (stycznia…grudnia) or Roman numerals (I…XII) and throws this RuntimeException otherwise. Unlike the weekday mapping it uses equals(), not startsWith, so any inflected or abbreviated variant fails.","triggerScenarios":"A rule matches a month in a case not exactly equal to the expected genitive form (e.g. nominative 'styczeń', 'lipiec') or a Roman numeral outside the listed ones; case mismatch ('Lipca').","commonSituations":"Dates written with nominative month names or non-standard abbreviations ('sty', 'wrz'); uppercase Roman numerals vs lowercase ('vii').","solutions":["Extend getMonth with equals()/startsWith branches for the form shown in the message","Normalize case before comparing (toLowerCase for names, toUpperCase for Roman numerals)","Restrict the rule regex to the exact forms the mapping supports, or map additional inflections"],"exampleFix":"// before\nif (mon.equals(\"grudnia\") || monthStr.equals(\"XII\")) return 12;\nthrow new RuntimeException(\"Could not find month '\" + monthStr + \"'\");\n// after\nif (mon.equals(\"grudnia\") || monthStr.equalsIgnoreCase(\"XII\")) return 12;\nif (mon.equals(\"grudzień\") || mon.equals(\"gru\")) return 12; // accept extra forms as needed\nthrow new RuntimeException(\"Could not find month '\" + monthStr + \"'\");","handlingStrategy":"validation","validationCode":"Set<String> ok = Set.of(\"stycznia\",\"lutego\",\"marca\",\"kwietnia\",\"maja\",\"czerwca\",\"lipca\",\"sierpnia\",\"września\",\"października\",\"listopada\",\"grudnia\",\"I\",\"II\",\"III\",\"IV\",\"V\",\"VI\",\"VII\",\"VIII\",\"IX\",\"X\",\"XI\",\"XII\");\nif (!ok.contains(monthStr)) throw new IllegalArgumentException(\"Unrecognized Polish month: \" + monthStr);","typeGuard":"boolean isPolishMonth(String s) { return s != null && (Set.of(\"stycznia\",\"lutego\",\"marca\",\"kwietnia\",\"maja\",\"czerwca\",\"lipca\",\"sierpnia\",\"września\",\"października\",\"listopada\",\"grudnia\").contains(s) || s.matches(\"[IVX]+\")); }","tryCatchPattern":"try { month = filter.getMonth(monthStr); } catch (RuntimeException e) { log.warn(\"Polish month unmatched: {}\", monthStr); return null; }","preventionTips":["getMonth uses exact equals: only pass the genitive forms or uppercase Roman numerals","Normalize case for Roman numerals (accept only I…XII uppercase)","Cover every month form in the rule regex with a unit test"],"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-14T05:17:10.506Z"}