{"record":{"id":"7e53ab73a58114c9","repo":"languagetool-org/languagetool","slug":"unknown-mode","errorCode":null,"errorMessage":"Unknown mode: ","messagePattern":"Unknown mode: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"languagetool-dev/src/main/java/org/languagetool/dev/bigdata/FrequencyIndexCreator.java","lineNumber":369,"sourceCode":"      writer.close();\n    }\n  }\n\n  public static void main(String[] args) throws Exception {\n    if (args.length != 3) {\n      System.out.println(\"Usage: \" + FrequencyIndexCreator.class.getSimpleName() + \" <text|lucene> <inputDir> <outputDir>\");\n      System.out.println(\"    <text|lucene> 'text' will write plain text files, 'lucene' will write Lucene indexes\");\n      System.out.println(\"    <inputDir> is the Google ngram data, optionally already aggregated by Hive (lucene mode),\");\n      System.out.println(\"               please see https://dev.languagetool.org/finding-errors-using-n-gram-data\");\n      System.exit(1);\n    }\n    Mode mode;\n    if (args[0].equals(\"text\")) {\n      mode = Mode.PlainText;\n    } else if (args[0].equals(\"lucene\")) {\n      mode = Mode.Lucene;\n    } else {\n      throw new RuntimeException(\"Unknown mode: \" + args[0]);\n    }\n    FrequencyIndexCreator creator = new FrequencyIndexCreator(mode);\n    System.out.println(\"Mode: \" + mode);\n    System.out.println(\"Minimum year: \" + MIN_YEAR);\n    System.out.println(\"Ignore POS tags: \" + IGNORE_POS);\n    creator.run(new File(args[1]), new File(args[2]));\n  }\n}\n","sourceCodeStart":351,"sourceCodeEnd":378,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-dev/src/main/java/org/languagetool/dev/bigdata/FrequencyIndexCreator.java#L351-L378","documentation":"FrequencyIndexCreator.main accepts only 'text' or 'lucene' as its first CLI argument, mapping to the Mode enum. Any other first argument throws this RuntimeException. This is strict argument validation for the dev indexing tool.","triggerScenarios":"Passing a mode string other than 'text' or 'lucene' (e.g. 'plain', 'Text' with capital letter, 'google') as args[0]; passing fewer than 3 args causing wrong element use.","commonSituations":"Following outdated documentation that used different mode names; case-sensitivity mistakes; copy-pasting an invocation for a different tool.","solutions":["Use exactly 'text' for plain text input or 'lucene' for Lucene input as the first argument","Ensure the mode string is lowercase","Check the invocation has the full form: <mode> <inputDir> <indexBaseDir>"],"exampleFix":"// before\njava FrequencyIndexCreator plain /data/input /data/index\n// after\njava FrequencyIndexCreator text /data/input /data/index","handlingStrategy":"validation","validationCode":"String mode = args.length > 0 ? args[0] : \"\";\nif (!mode.equals(\"text\") && !mode.equals(\"lucene\")) {\n  throw new IllegalArgumentException(\"mode must be 'text' or 'lucene', got: \" + mode);\n}","typeGuard":null,"tryCatchPattern":"try {\n  FrequencyIndexCreator.main(args);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Unknown mode\")) {\n    System.err.println(\"Usage: FrequencyIndexCreator <text|lucene> <inputDir> <indexBaseDir>\");\n  }\n}","preventionTips":["Wrap invocations in a script that validates args[0] against text|lucene","Remember the mode string is case-sensitive and lowercase","Check current tool usage/README for accepted mode names"],"tags":["cli","invalid-argument","enum"],"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"}