{"record":{"id":"c32d82bb68de5113","repo":"languagetool-org/languagetool","slug":"could-not-load-simple-replacement-data-from-p-c32d82","errorCode":null,"errorMessage":"Could not load simple replacement data from: \" + path + \". Error in line '\" + line + \"', replacement cannot be empty","messagePattern":"Could not load simple replacement data from: \" \\+ path \\+ \"\\. Error in line '\" \\+ line \\+ \"', replacement cannot be empty","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/rules/SimpleReplaceDataLoader.java","lineNumber":53,"sourceCode":"  /**\n   * Load replacement rules from a utf-8 file in the classpath.\n   */\n  public Map<String, List<String>> loadWords(String path) {\n    InputStream stream = JLanguageTool.getDataBroker().getFromRulesDirAsStream(path);\n    Map<String, List<String>> map = new HashMap<>();\n    try (Scanner scanner = new Scanner(stream, \"utf-8\")) {\n      while (scanner.hasNextLine()) {\n        String line = scanner.nextLine();\n        if (line.isEmpty() || line.charAt(0) == '#') { // # = comment\n          continue;\n        }\n        String[] parts = line.split(\"=\");\n        if (parts.length != 2) {\n          throw new RuntimeException(\"Could not load simple replacement data from: \" + path + \". \" +\n                  \"Error in line '\" + line + \"', expected format 'word=replacement'\");\n        }\n        if (parts[1].trim().isEmpty()) {\n          throw new RuntimeException(\"Could not load simple replacement data from: \" + path + \". \" +\n            \"Error in line '\" + line + \"', replacement cannot be empty\");\n        }\n        String[] wrongForms = parts[0].split(\"\\\\|\");\n        List<String> replacements = Arrays.asList(parts[1].split(\"\\\\|\"));\n        for (String wrongForm : wrongForms) {\n          map.put(wrongForm, replacements);\n        }\n      }\n    }\n    return Collections.unmodifiableMap(map);\n  }\n\n}\n","sourceCodeStart":35,"sourceCodeEnd":67,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/rules/SimpleReplaceDataLoader.java#L35-L67","documentation":"SimpleReplaceDataLoader.loadWords parses a rule-replacement file where each line must be 'wrongForm=replacement'. This RuntimeException is thrown when the right-hand side of the '=' is empty after trimming, i.e. the data file contains a line like 'word=' with no replacement.","triggerScenarios":"Calling loadFromPath/loadWords on a replacement data file that contains a line with an empty replacement, e.g. 'mispeled=' (nothing after '=').","commonSituations":"Hand-edited or incomplete language rule data files in the language resource directories; a contributor deleted the replacement but left the word; file truncated during commit.","solutions":["Open the file at 'path' named in the exception and find the offending line printed in the message.","Add a non-empty replacement after the '=' (or remove the line if the entry is not wanted).","Split multiple replacements with '|' if needed, e.g. 'word=fix1|fix2'."],"exampleFix":"// before (data file)\nmispeled=\n// after (data file)\nmispeled=misspelled","handlingStrategy":"validation","validationCode":"// validate replacement data lines before loading\nfor (String line : Files.readAllLines(Paths.get(path))) {\n    if (line.isEmpty() || line.startsWith(\"#\")) continue;\n    String[] parts = line.split(\"=\", -1);\n    if (parts.length != 2 || parts[1].trim().isEmpty())\n        throw new IllegalStateException(\"Bad line in \" + path + \": \" + line);\n}","typeGuard":null,"tryCatchPattern":"try { loader.loadWords(path, language); } catch (RuntimeException e) { log.error(\"Invalid replacement data: \" + e.getMessage()); throw e; }","preventionTips":["Run a linter/CI check on rule data files for empty replacements","Never commit replacement files with lines ending in '='","Test-load all language data files in unit tests"],"tags":["java","data-file","parsing","languagetool"],"backgroundTag":"empty-required-field","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"}