languagetool-org/languagetool · error · IllegalArgumentException
Unknown value '${indexPos}' for indexPosTags parameter, use
Error message
Unknown value '${indexPos}' for indexPosTags parameter, use 0 or 1 What it means
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.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/SentenceSourceIndexer.java:152
String languageCode = args[2];
int maxSentences = Integer.parseInt(args[3]);
Language language = Languages.getLanguageForShortCode(languageCode);
if (maxSentences == 0) {
System.out.println("Going to index contents from " + dumpFilesNames);
} else {
System.out.println("Going to index up to " + maxSentences + " sentences from " + dumpFilesNames);
}
System.out.println("Output index dir: " + indexDir);
long start = System.currentTimeMillis();
Analyzer analyzer;
String indexPos = args[4];
if (indexPos.equals("1")) {
analyzer = null; // this will use LanguageToolAnalyzer
} else if (indexPos.equals("0")) {
analyzer = new StandardAnalyzer(new CharArraySet(Collections.emptyList(), false));
} else {
throw new IllegalArgumentException("Unknown value '" + indexPos + "' for indexPosTags parameter, use 0 or 1");
}
try (FSDirectory fsDirectory = FSDirectory.open(indexDir.toPath());
SentenceSourceIndexer indexer = new SentenceSourceIndexer(fsDirectory, language, maxSentences, analyzer)) {
try {
indexer.run(dumpFilesNames, language);
} catch (DocumentLimitReachedException e) {
System.out.println("Sentence limit (" + e.getLimit() + ") reached, stopping indexing");
} finally {
indexer.writeMetaDocuments();
}
if (analyzer != null) {
analyzer.close();
}
}
long end = System.currentTimeMillis();
float minutes = (end - start) / (float)(1000 * 60);
System.out.printf("Indexing took %.2f minutes\n", minutes);
}View on GitHub (pinned to 2e990059ce)
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
Example fix
// before java ... indexDir en dump.xml maxSentences true // after java ... indexDir en dump.xml maxSentences 1
Defensive patterns
Strategy: validation
Validate before calling
String indexPos = args[4];
if (!indexPos.equals("0") && !indexPos.equals("1")) {
System.err.println("indexPosTags must be 0 or 1, got: " + indexPos);
System.exit(2);
} Try / catch
try {
SentenceSourceIndexer.main(args);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unknown value")) {
System.err.println("Fix the 5th argument (indexPosTags): " + e.getMessage());
} else throw e;
} Prevention
- 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
When it happens
Trigger: Calling the indexer with a 5th argument that isn't exactly "0" or "1", e.g. "true", "yes", "0 " with whitespace, or "no".
Common situations: Scripts passing boolean words instead of digits; copy-paste with trailing whitespace or quotes; outdated documentation suggesting other values.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- Unknown mode:
- WrongParameterNumberException
- Unknown level '<level>' - currently, only 'PICKY' is support
- You cannot list unknown words when tagging only
- You cannot apply suggestions when tagging only
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/346c7194234feaf8.
Report an issue: GitHub.