{"record":{"id":"e8bdbf725ca00243","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-args-argindex-e8bdbf","errorCode":null,"errorMessage":"Unknown argument ${args[argIndex]}","messagePattern":"Unknown argument (.+?)","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/dvparser/AverageDVModels.java","lineNumber":117,"sourceCode":"   * Command line arguments for this program:\n   * <br>\n   * -output: the model file to output\n   * -input: a list of model files to input\n   */\n  public static void main(String[] args) {\n    String outputModelFilename = null;\n    List<String> inputModelFilenames = Generics.newArrayList();\n    \n    for (int argIndex = 0; argIndex < args.length; ) {\n      if (args[argIndex].equalsIgnoreCase(\"-output\")) {\n        outputModelFilename = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-input\")) {\n        for (++argIndex; argIndex < args.length && !args[argIndex].startsWith(\"-\"); ++argIndex) {\n          inputModelFilenames.addAll(Arrays.asList(args[argIndex].split(\",\")));\n        }\n      } else {\n        throw new RuntimeException(\"Unknown argument \" + args[argIndex]);\n      }\n    }\n\n    if (outputModelFilename == null) {\n      log.info(\"Need to specify output model name with -output\");\n      System.exit(2);\n    }\n\n    if (inputModelFilenames.size() == 0) {\n      log.info(\"Need to specify input model names with -input\");\n      System.exit(2);\n    }\n\n    log.info(\"Averaging \" + inputModelFilenames);\n    log.info(\"Outputting result to \" + outputModelFilename);\n\n    LexicalizedParser lexparser = null;\n    List<DVModel> models = Generics.newArrayList();","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/dvparser/AverageDVModels.java#L99-L135","documentation":"AverageDVModels.main() throws this RuntimeException when it encounters a command-line argument it does not recognize during option parsing. Only flags like -output and -input are supported; any other token aborts the program.","triggerScenarios":"Running java edu.stanford.nlp.parser.dvparser.AverageDVModels with a typo'd or unsupported flag, or with a value accidentally separated from its flag so the value itself is parsed as a flag.","commonSituations":"Misspelling -input or -output; copying flags from another dvparser tool that supports more options; shell quoting dropping a value so its flag consumes the wrong tokens.","solutions":["Use only the supported flags: -output <name> and -input <comma-separated model files>","Fix the typo in the unrecognized argument","Check shell quoting so values stay attached to their flags"],"exampleFix":"// before\njava AverageDVModels -model parser.gz -output avg.gz\n// after\njava AverageDVModels -input parser1.gz,parser2.gz -output avg.gz","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"-output\", \"-input\");\nfor (String a : args) if (a.startsWith(\"-\") && !allowed.contains(a)) throw new IllegalArgumentException(\"unsupported flag: \" + a);","typeGuard":null,"tryCatchPattern":"try { AverageDVModels.main(args); } catch (RuntimeException e) { System.err.println(\"Bad dvparser arguments: \" + e.getMessage()); System.exit(1); }","preventionTips":["Check the accepted flags in the source before invoking dvparser tools","Use a launcher script that validates flags before calling main","Keep flag values quoted so parsing stays aligned"],"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"}