{"record":{"id":"14feb6dc8de85038","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-args-argindex-14feb6","errorCode":null,"errorMessage":"Unknown argument ${args[argIndex]}","messagePattern":"Unknown argument (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java","lineNumber":229,"sourceCode":"        continue;\n      }\n      if (args[argIndex].equalsIgnoreCase(\"-output\")) {\n        output = args[argIndex + 1];\n        argIndex += 2;\n        continue;\n      }\n      if (args[argIndex].equalsIgnoreCase(\"-treebank\")) {\n        Pair<String, FileFilter> treebankDescription = ArgUtils.getTreebankDescription(args, argIndex, \"-treebank\");\n        argIndex = argIndex + ArgUtils.numSubArgs(args, argIndex) + 1;\n        treebanks.add(treebankDescription);\n        continue;\n      }\n      if (args[argIndex].equalsIgnoreCase(\"-numThreads\")) {\n        numThreads = Integer.parseInt(args[argIndex + 1]);\n        argIndex += 2;\n        continue;\n      }\n      throw new IllegalArgumentException(\"Unknown argument \" + args[argIndex]);\n    }\n\n    if (parserModel == null) {\n      throw new IllegalArgumentException(\"Need to supply a parser model with -model\");\n    }\n    if (output == null) {\n      throw new IllegalArgumentException(\"Need to supply an output filename with -output\");\n    }\n    if (treebanks.isEmpty()) {\n      throw new IllegalArgumentException(\"Need to supply a treebank with -treebank\");\n    }\n\n    log.info(\"Writing output to \" + output);\n    log.info(\"Loading parser model \" + parserModel);\n    log.info(\"Writing \" + dvKBest + \" hypothesis trees for each tree\");\n\n    LexicalizedParser parser = LexicalizedParser.loadModel(parserModel, \"-dvKBest\", Integer.toString(dvKBest));\n    CacheParseHypotheses cacher = new CacheParseHypotheses(parser);","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/CacheParseHypotheses.java#L211-L247","documentation":"CacheParseHypotheses.main() throws this IllegalArgumentException when an unrecognized argument is passed to its option parser. The tool only accepts flags such as -model, -output, and -numThreads; anything else is rejected.","triggerScenarios":"Running CacheParseHypotheses with an unsupported flag, or a flag whose value was quoted incorrectly so the parser lands on the wrong token.","commonSituations":"Passing options borrowed from other dvparser main classes that this tool does not implement; typos in flag names like -model; missing values causing misalignment of the arg loop.","solutions":["Restrict arguments to the supported flags: -model, -output, -numThreads","Fix the typo in the offending argument","Ensure every flag's value is present and properly quoted"],"exampleFix":"// before\njava CacheParseHypotheses -model parser.gz -cacheFile out\n// after\njava CacheParseHypotheses -model parser.gz -output out","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"-model\", \"-output\", \"-numThreads\");\nfor (String a : args) if (a.startsWith(\"-\") && !allowed.contains(a)) throw new IllegalArgumentException(\"unsupported flag: \" + a);","typeGuard":null,"tryCatchPattern":"try { CacheParseHypotheses.main(args); } catch (IllegalArgumentException e) { System.err.println(\"Bad arguments: \" + e.getMessage()); System.exit(1); }","preventionTips":["Only pass -model, -output, -numThreads to CacheParseHypotheses","Always supply -model (required, checked immediately after parsing)","Validate your command line with a dry-run wrapper before running the tool"],"tags":["java","command-line","dvparser"],"backgroundTag":"invalid-cli-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}