{"record":{"id":"346c7194234feaf8","repo":"languagetool-org/languagetool","slug":"unknown-value-indexpos-for-indexpostags-param","errorCode":null,"errorMessage":"Unknown value '${indexPos}' for indexPosTags parameter, use 0 or 1","messagePattern":"Unknown value '(.+?)' for indexPosTags parameter, use 0 or 1","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/SentenceSourceIndexer.java","lineNumber":152,"sourceCode":"    String languageCode = args[2];\n    int maxSentences = Integer.parseInt(args[3]);\n\n    Language language = Languages.getLanguageForShortCode(languageCode);\n    if (maxSentences == 0) {\n      System.out.println(\"Going to index contents from \" + dumpFilesNames);\n    } else {\n      System.out.println(\"Going to index up to \" + maxSentences + \" sentences from \" + dumpFilesNames);\n    }\n    System.out.println(\"Output index dir: \" + indexDir);\n    long start = System.currentTimeMillis();\n    Analyzer analyzer;\n    String indexPos = args[4];\n    if (indexPos.equals(\"1\")) {\n      analyzer = null;  // this will use LanguageToolAnalyzer\n    } else if (indexPos.equals(\"0\")) {\n      analyzer = new StandardAnalyzer(new CharArraySet(Collections.emptyList(), false));\n    } else {\n      throw new IllegalArgumentException(\"Unknown value '\" + indexPos + \"' for indexPosTags parameter, use 0 or 1\");\n    }\n    try (FSDirectory fsDirectory = FSDirectory.open(indexDir.toPath());\n         SentenceSourceIndexer indexer = new SentenceSourceIndexer(fsDirectory, language, maxSentences, analyzer)) {\n      try {\n        indexer.run(dumpFilesNames, language);\n      } catch (DocumentLimitReachedException e) {\n        System.out.println(\"Sentence limit (\" + e.getLimit() + \") reached, stopping indexing\");\n      } finally {\n        indexer.writeMetaDocuments();\n      }\n      if (analyzer != null) {\n        analyzer.close();\n      }\n    }\n    long end = System.currentTimeMillis();\n    float minutes = (end - start) / (float)(1000 * 60);\n    System.out.printf(\"Indexing took %.2f minutes\\n\", minutes);\n  }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/SentenceSourceIndexer.java#L134-L170","documentation":"SentenceSourceIndexer.main takes the indexPosTags argument (args[4]) which selects whether positional tags are indexed: '0' uses StandardAnalyzer (no position tags), '1' uses LanguageToolAnalyzer. Any other value throws an IllegalArgumentException. It is a strict two-value enum check on a CLI parameter.","triggerScenarios":"Calling the indexer with a 5th argument that isn't exactly \"0\" or \"1\", e.g. \"true\", \"yes\", \"0 \" with whitespace, or \"no\".","commonSituations":"Scripts passing boolean words instead of digits; copy-paste with trailing whitespace or quotes; outdated documentation suggesting other values.","solutions":["Pass exactly 0 or 1 as the fifth argument","Trim quotes/whitespace in the calling script","Check your wrapper script's argument ordering so args[4] is really the indexPosTags value"],"exampleFix":"// before\njava ... indexDir en dump.xml maxSentences true\n// after\njava ... indexDir en dump.xml maxSentences 1","handlingStrategy":"validation","validationCode":"String indexPos = args[4];\nif (!indexPos.equals(\"0\") && !indexPos.equals(\"1\")) {\n  System.err.println(\"indexPosTags must be 0 or 1, got: \" + indexPos);\n  System.exit(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n  SentenceSourceIndexer.main(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown value\")) {\n    System.err.println(\"Fix the 5th argument (indexPosTags): \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Quote and trim arguments in wrapper scripts","Use a case statement validating 0|1 in shell","Fix argument ordering so args[4] is the right parameter","Document allowed values in scripts"],"tags":["cli","invalid-argument","indexing"],"backgroundTag":"invalid-cli-argument","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"}