languagetool-org/languagetool · error · IllegalArgumentException
Unknown level '<level>' - currently, only 'PICKY' is support
Error message
Unknown level '<level>' - currently, only 'PICKY' is supported
What it means
When parsing `--level`, parseOptions() tries JLanguageTool.Level.valueOf(level). If the value is not a defined Level enum constant, it rethrows IllegalArgumentException with this message, since the CLI currently only implements the PICKY level.
Source
Thrown at languagetool-commandline/src/main/java/org/languagetool/commandline/CommandLineParser.java:61
options.setPrintLanguages(true);
} else if (args[i].equals("-h") || args[i].equals("-help") || args[i].equals("--help") || args[i].equals("--?")) {
options.setPrintUsage(true);
} else if (args[i].equals("-adl") || args[i].equals("--autoDetect")) { // set autoDetect flag
options.setAutoDetect(true);
} else if (args[i].equals("-v") || args[i].equals("--verbose")) {
options.setVerbose(true);
} else if (args[i].equals("--line-by-line")) {
options.setLineByLine(true);
} else if (args[i].equals("--enable-temp-off")) {
options.setEnableTempOff(true);
} else if (args[i].equals("--clean-overlapping")) {
options.setCleanOverlapping(true);
} else if (args[i].equals("--level")) {
String level = args[++i];
try {
options.setLevel(JLanguageTool.Level.valueOf(level));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Unknown level '" + level + "' - currently, only 'PICKY' is supported");
}
} else if (args[i].equals("-t") || args[i].equals("--taggeronly")) {
options.setTaggerOnly(true);
if (options.isListUnknown()) {
throw new IllegalArgumentException("You cannot list unknown words when tagging only");
}
if (options.isApplySuggestions()) {
throw new IllegalArgumentException("You cannot apply suggestions when tagging only");
}
} else if (args[i].equals("-r") || args[i].equals("--recursive")) {
options.setRecursive(true);
} else if (args[i].equals("-b2") || args[i].equals("--bitext")) {
options.setBitext(true);
} else if (args[i].equals("-eo") || args[i].equals("--enabledonly")) {
if (options.getDisabledRules().size() > 0) {
throw new IllegalArgumentException("You cannot specify both disabled rules and enabledonly");
}
options.setUseEnabledOnly();View on GitHub (pinned to 2e990059ce)
Solutions
- Use exactly `--level PICKY` (uppercase).
- Omit --level entirely to use the default level.
- Check the JLanguageTool.Level enum constants for the accepted values.
- Wrap your own call to parseOptions/Main in a try-catch for IllegalArgumentException if you build commands dynamically.
Example fix
// before languagetool --level picky file.txt // after languagetool --level PICKY file.txt
Defensive patterns
Strategy: validation
Validate before calling
String level = System.getenv("LT_LEVEL");
if (level != null && !level.equals("PICKY")) {
throw new IllegalArgumentException("--level must be exactly 'PICKY'");
} Try / catch
try {
new CommandLineParser().parseOptions(args);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unknown level")) {
System.err.println("Use --level PICKY (uppercase); it is the only supported level.");
}
} Prevention
- Always write the level in uppercase: PICKY.
- Check JLanguageTool.Level enum constants before passing a value.
- Validate user-supplied level strings in wrapper scripts before invoking the CLI.
When it happens
Trigger: `languagetool --level picky file.txt` (wrong case), `--level PICKYALL`, or any misspelled/unimplemented level name passed after --level.
Common situations: Copy-pasting level names from other tools or docs; assuming case-insensitivity; assuming more levels exist in the CLI than the enum (only PICKY is wired up).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown mode:
- WrongParameterNumberException
- You cannot list unknown words when tagging only
- You cannot apply suggestions when tagging only
- You cannot specify both disabled rules and enabledonly
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/9bea4ea5e32e2413.
Report an issue: GitHub.