{"record":{"id":"dbd4b9b9630a9e43","repo":"stanfordnlp/CoreNLP","slug":"unknown-argument-dbd4b9","errorCode":null,"errorMessage":"Unknown argument ","messagePattern":"Unknown argument ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/SentimentPipeline.java","lineNumber":298,"sourceCode":"        String[] formats = args[argIndex + 1].split(\",\");\n        outputFormats = new ArrayList<>();\n        for (String format : formats) {\n          outputFormats.add(Output.valueOf(format.toUpperCase(Locale.ROOT)));\n        }\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-filterUnknown\")) {\n        filterUnknown = true;\n        argIndex++;\n      } else if (args[argIndex].equalsIgnoreCase(\"-tlppClass\")) {\n        tlppClass = args[argIndex + 1];\n        argIndex += 2;\n      } else if (args[argIndex].equalsIgnoreCase(\"-help\")) {\n        help();\n        System.exit(0);\n      } else {\n        log.info(\"Unknown argument \" + args[argIndex + 1]);\n        help();\n        throw new IllegalArgumentException(\"Unknown argument \" + args[argIndex + 1]);\n      }\n    }\n\n    // We construct two pipelines.  One handles tokenization, if\n    // necessary.  The other takes tokenized sentences and converts\n    // them to sentiment trees.\n    Properties pipelineProps = new Properties();\n    Properties tokenizerProps = null;\n    if (sentimentModel != null) {\n      pipelineProps.setProperty(\"sentiment.model\", sentimentModel);\n    }\n    if (parserModel != null) {\n      pipelineProps.setProperty(\"parse.model\", parserModel);\n    }\n    if (inputFormat == Input.TREES) {\n      pipelineProps.setProperty(\"annotators\", \"binarizer, sentiment\");\n      pipelineProps.setProperty(\"customAnnotatorClass.binarizer\", \"edu.stanford.nlp.pipeline.BinarizerAnnotator\");\n      pipelineProps.setProperty(\"binarizer.tlppClass\", tlppClass);","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/SentimentPipeline.java#L280-L316","documentation":"SentimentPipeline.main parses command-line arguments in a loop; when an argument matches none of the known flags, it logs, prints help, and throws IllegalArgumentException(\"Unknown argument \" + ...). Note the message reads args[argIndex + 1], so it may show the wrong token, but the offending flag is args[argIndex].","triggerScenarios":"Invoking the pipeline with a flag not in its accepted set (e.g. -outputFormat instead of -output, -inputFile instead of -file), or passing a bare positional argument that isn't a recognized option.","commonSituations":"Copy-pasting flags from StanfordCoreNLP into SentimentPipeline (the flag sets differ); typos like -model vs -mod; scripts passing an extra positional argument; quoting mistakes that split flags.","solutions":["Run with -help and use only the listed flags for SentimentPipeline.","Correct the misspelled flag (e.g. -file, -fileList, -stdin, -model, -output, -input).","Remove extra positional arguments; all inputs must go through -file, -fileList, or -stdin.","In wrapper scripts, echo the full command and verify each flag against the -help output; note the error text may name the token after the bad flag, so check the preceding argument too."],"exampleFix":"// before\njava edu.stanford.nlp.sentiment.SentimentPipeline -outputFormat scores -file in.txt\n// after\njava edu.stanford.nlp.sentiment.SentimentPipeline -output scores -file in.txt","handlingStrategy":"validation","validationCode":"Set<String> knownFlags = new HashSet<>(Arrays.asList(\"-model\",\"-file\",\"-fileList\",\"-stdin\",\"-output\",\"-input\",\"-help\",\"-tokenizerModel\",\"-taggerModel\"));\nfor (String a : args) {\n  if (a.startsWith(\"-\") && !knownFlags.contains(a)) {\n    throw new IllegalArgumentException(\"Unsupported flag for SentimentPipeline: \" + a);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  SentimentPipeline.main(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown argument\")) {\n    // the message may show args[i+1]; re-check args[i-1] and args[i]\n    System.err.println(\"Inspect all flags against -help; bad flag likely precedes: \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["Run -help and diff every flag in your script against it.","Do not reuse flag sets from StanfordCoreNLP; SentimentPipeline accepts a different subset.","Quote arguments so flags with values aren't split by the shell.","Note the error text prints args[argIndex + 1], so the actual bad flag is one position earlier."],"tags":["java","cli","argument-parsing","nlp"],"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"}