{"record":{"id":"5963d3e5456585e8","repo":"languagetool-org/languagetool","slug":"the-ruleidtoconfidencefile-parameter-must-contai","errorCode":null,"errorMessage":"The 'ruleIdToConfidenceFile' parameter must contain '{lang}' as a placeholder for the language code","messagePattern":"The 'ruleIdToConfidenceFile' parameter must contain '(.+?)' as a placeholder for the language code","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"languagetool-server/src/main/java/org/languagetool/server/ConfidenceMapLoader.java","lineNumber":43,"sourceCode":"import org.slf4j.LoggerFactory;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport static java.nio.charset.StandardCharsets.UTF_8;\n\nclass ConfidenceMapLoader {\n\n  private static final Logger logger = LoggerFactory.getLogger(ConfidenceMapLoader.class);\n\n  Map<ConfidenceKey,Float> load(File filePattern) throws IOException {\n    if (!filePattern.toString().contains(\"{lang}\")) {\n      throw new RuntimeException(\"The 'ruleIdToConfidenceFile' parameter must contain '{lang}' as a placeholder for the language code\");\n    }\n    Map<ConfidenceKey,Float> confMap = new HashMap<>();\n    for (Language lang : Languages.get()) {\n      int loadCount = 0;\n      String fileName = filePattern.getAbsolutePath().replace(\"{lang}\", lang.getShortCode());\n      if (!Paths.get(fileName).toFile().exists()) {\n        continue;\n      }\n      List<String> lines = Files.readAllLines(Paths.get(fileName), UTF_8);\n      for (String line : lines) {\n        if (line.startsWith(\"#\")) {\n          continue;\n        }\n        String[] parts = line.split(\",\");\n        if (parts.length >= 2) {   // there might be more columns for better debugging, but we don't use them here\n          try {\n            float confidence = Float.parseFloat(parts[1]);\n            confMap.put(new ConfidenceKey(lang, parts[0]), confidence);","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-server/src/main/java/org/languagetool/server/ConfidenceMapLoader.java#L25-L61","documentation":"ConfidenceMapLoader.load expects a file path pattern containing the literal '{lang}' placeholder, which is substituted per language short code when loading rule confidence mappings. A pattern without '{lang}' cannot be expanded per language and throws RuntimeException at startup.","triggerScenarios":"Starting languagetool-server with the 'ruleIdToConfidenceFile' config parameter set to a plain path like /conf/confidence.csv instead of /conf/confidence-{lang}.csv.","commonSituations":"Copying a single-language confidence file config into a multi-language deployment; misreading the parameter name as a plain file path.","solutions":["Add '{lang}' to the configured file path, e.g. /path/confidence-{lang}.csv.","Create per-language files matching the pattern (confidence-en.csv, confidence-de.csv, ...).","Restart the server after fixing the config value."],"exampleFix":"// before\nruleIdToConfidenceFile=/etc/languagetool/confidence.csv\n// after\nruleIdToConfidenceFile=/etc/languagetool/confidence-{lang}.csv","handlingStrategy":"validation","validationCode":"if (!confidenceFilePattern.includes('{lang}')) {\n  throw new Error(\"ruleIdToConfidenceFile must contain '{lang}'\");\n}","typeGuard":"function isValidLangPattern(p) { return typeof p === 'string' && p.includes('{lang}'); }","tryCatchPattern":"try {\n  Map<ConfidenceKey,Float> map = new ConfidenceMapLoader().load(filePattern);\n} catch (RuntimeException e) {\n  logger.error(\"Bad confidence file pattern: \" + e.getMessage());\n}","preventionTips":["Include {lang} in any per-language file pattern config.","Document the pattern requirement next to the config key.","Smoke-test server startup with the configured pattern."],"tags":["config","languagetool","startup"],"backgroundTag":"invalid-config-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"}