{"record":{"id":"90a30c4dcc8e6d2a","repo":"languagetool-org/languagetool","slug":"incorrect-number-of-fields-line","errorCode":null,"errorMessage":"Incorrect number of fields: \" + line","messagePattern":"Incorrect number of fields: \" \\+ line","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-language-modules/ga/src/main/java/org/languagetool/rules/ga/DativePluralsData.java","lineNumber":54,"sourceCode":"  public static Map<String, String> getSimpleReplacements() {\n    return simpleReplacements;\n  }\n\n  /**\n   * Load words.\n   */\n  private static Set<DativePluralsEntry> loadWords(String path) {\n    Set<DativePluralsEntry> set = new HashSet<>();\n    InputStream stream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);\n    try (Scanner scanner = new Scanner(stream, \"utf-8\")) {\n      while (scanner.hasNextLine()) {\n        String line = scanner.nextLine().trim();\n        if (line.isEmpty() || line.charAt(0) == '#') {\n          continue;\n        }\n        String[] parts = line.split(\";\");\n        if (parts.length != 4) {\n          throw new RuntimeException(\"Incorrect number of fields: \" + line);\n        }\n        String form = parts[0];\n        String formModern = null;\n        if (form.contains(\":\")) {\n          String[] forms = form.split(\":\");\n          if (forms.length != 2) {\n            throw new RuntimeException(\"Form has more than 1 modern form:\" + line);\n          }\n          form = forms[0];\n          formModern = forms[1];\n        }\n        String repl = parts[3];\n        String replModern = null;\n        if (repl.contains(\":\")) {\n          String[] repls = repl.split(\":\");\n          if (repls.length != 2) {\n            throw new RuntimeException(\"Replacement has more than 1 modern form:\" + line);\n          }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-language-modules/ga/src/main/java/org/languagetool/rules/ga/DativePluralsData.java#L36-L72","documentation":"DativePluralsData.loadWords parses a semicolon-separated data file (Irish dative plurals) and requires exactly 4 fields per line. A line with any other field count throws this RuntimeException naming the offending line, so a malformed data resource fails fast at load time.","triggerScenarios":"A line in the dative plurals resource file contains fewer or more than 4 semicolon-separated fields (e.g. a missing ';' or an extra one), and is not blank or commented with '#'.","commonSituations":"Manual edits to the .txt data file; contributors appending columns; CSV editors re-quoting or altering separators; copy-paste losing a trailing field.","solutions":["Open the resource file (e.g. src/main/resources/.../ga/dative-plurals.txt) and fix the line printed in the message to have exactly 4 semicolon-separated fields.","If extra data is needed, add a new column consistently to every line and update the parser, not just one line.","Check whether a value itself contains a ';' that must be removed or escaped.","Add a unit test that loads the data file so format drift is caught in CI."],"exampleFix":"// before (3 fields)\nabha; abh; NMOL\n// after (4 fields)\nabha:abhaí; abha; f; NMOL","handlingStrategy":"validation","validationCode":"for (String line : Files.readAllLines(path)) {\n  if (line.isBlank() || line.startsWith(\"#\")) continue;\n  if (line.split(\";\", -1).length != 4) throw new IllegalStateException(\"bad line: \" + line);\n}","typeGuard":null,"tryCatchPattern":"try { DativesData.datives(); } catch (RuntimeException e) { log.error(\"Data file corrupt: \" + e.getMessage()); throw e; }","preventionTips":["Lint the data file in CI (field count, colon counts per field)","Avoid editing data files with spreadsheet tools that alter separators","Keep a header comment documenting the 4-field format"],"tags":["java","languagetool","data-file","irish"],"backgroundTag":"schema-validation-failed","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"}