languagetool-org/languagetool · error · IllegalArgumentException

must be set

Error message

 must be set

What it means

When a dynamic language `lang-xx` property is defined, LanguageTool requires a companion property `lang-xx-dictPath` pointing at the hunspell/morfologik dictionary file for that language's spell checker. This IllegalArgumentException is thrown when that dictPath property is missing from the config.

Source

Thrown at languagetool-server/src/main/java/org/languagetool/server/HTTPServerConfig.java:539

    } catch (IOException e) {
      throw new RuntimeException("Could not load properties from '" + file + "'", e);
    }
  }

  private void addDynamicLanguages(Properties props) throws IOException {
    for (Object keyObj : props.keySet()) {
      String key = (String)keyObj;
      if (key.startsWith("lang-") && !key.contains("-dictPath")) {
        String code = key.substring("lang-".length());
        if (!code.contains("-") && code.length() != 2 && code.length() != 3) {
          throw new IllegalArgumentException("code is supposed to be a 2 (or rarely 3) character code (unless it uses a format with variant, like xx-YY): '" + code + "'");
        }
        String nameKey = "lang-" + code;
        String name = props.getProperty(nameKey);
        String dictPathKey = "lang-" + code + "-dictPath";
        String dictPath = props.getProperty(dictPathKey);
        if (dictPath == null) {
          throw new IllegalArgumentException(dictPathKey + " must be set");
        }
        File dictPathFile = new File(dictPath);
        if (!dictPathFile.exists() || !dictPathFile.isFile()) {
          throw new IllegalArgumentException("dictionary file does not exist or is not a file: '" + dictPath + "'");
        }
        ServerTools.print("Adding dynamic spell checker language " + name + ", code: " + code + ", dictionary: " + dictPath);
        Language lang = Languages.addLanguage(name, code, new File(dictPath));
        // better fail early in case of misconfiguration, so use the language now:
        if (!new File(lang.getCommonWordsPath()).exists()) {
          throw new IllegalArgumentException("Common words path not found: '" + lang.getCommonWordsPath() + "'");
        }
        JLanguageTool lt = new JLanguageTool(lang);
        lt.check("test");
      }
    }
  }

  public void setLanguageModelDirectory(String langModelDir) {

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Add the missing property, e.g. `lang-de-dictPath=/path/to/de.dict` next to the `lang-de` entry
  2. Check exact spelling/casing of the property key suffix: it must be exactly `-dictPath`
  3. Remove the `lang-xx` entry entirely if no custom language was intended

Example fix

// before (properties)
lang-de=German (custom)
// after (properties)
lang-de=German (custom)
lang-de-dictPath=/opt/languagetool/dicts/de.dict
Defensive patterns

Strategy: validation

Validate before calling

for (String key : props.stringPropertyNames()) {
  if (key.startsWith("lang-") && !key.endsWith("-dictPath")) {
    String code = key.substring("lang-".length());
    if (!props.containsKey("lang-" + code + "-dictPath"))
      throw new IllegalStateException("Missing lang-" + code + "-dictPath");
  }
}

Try / catch

try {
  serverConfig.checkConsistency();
} catch (IllegalArgumentException e) {
  LOG.error("Invalid dynamic language config: {}", e.getMessage());
  System.exit(1);
}

Prevention

When it happens

Trigger: A config properties file defines `lang-xx=Some Language` (or a valid `lang-xx*` key) but no `lang-xx-dictPath=...` entry exists in the same Properties object.

Common situations: Admins add a custom language entry but forget the `-dictPath` companion property, or misspell it (e.g. `lang-de-dictpath` with wrong case or `-dictionary` instead of `-dictPath`).

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/17093e74ee1186ab. Report an issue: GitHub.