{"record":{"id":"5205a00f7f4c4725","repo":"stanfordnlp/CoreNLP","slug":"please-only-specify-one-of-file-filelist-or-st","errorCode":null,"errorMessage":"Please only specify one of -file, -fileList or -stdin","messagePattern":"Please only specify one of -file, -fileList or -stdin","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/SentimentPipeline.java","lineNumber":336,"sourceCode":"    } else {\n      pipelineProps.setProperty(\"annotators\", \"parse, sentiment\");\n      pipelineProps.setProperty(\"parse.binaryTrees\", \"true\");\n      pipelineProps.setProperty(\"parse.buildgraphs\", \"false\");\n      pipelineProps.setProperty(\"enforceRequirements\", \"false\");\n      tokenizerProps = new Properties();\n      tokenizerProps.setProperty(\"annotators\", \"tokenize, ssplit\");\n    }\n\n    if (stdin && tokenizerProps != null) {\n      tokenizerProps.setProperty(StanfordCoreNLP.NEWLINE_SPLITTER_PROPERTY, \"true\");\n    }\n\n    int count = 0;\n    if (filename != null) count++;\n    if (fileList != null) count++;\n    if (stdin) count++;\n    if (count > 1) {\n      throw new IllegalArgumentException(\"Please only specify one of -file, -fileList or -stdin\");\n    }\n    if (count == 0) {\n      throw new IllegalArgumentException(\"Please specify either -file, -fileList or -stdin\");\n    }\n\n    StanfordCoreNLP tokenizer = (tokenizerProps == null) ? null : new StanfordCoreNLP(tokenizerProps);\n    StanfordCoreNLP pipeline = new StanfordCoreNLP(pipelineProps);\n\n    if (filename != null) {\n      // Process a file.  The pipeline will do tokenization, which\n      // means it will split it into sentences as best as possible\n      // with the tokenizer.\n      List<Annotation> annotations = getAnnotations(tokenizer, inputFormat, filename, filterUnknown);\n      for (Annotation annotation : annotations) {\n        pipeline.annotate(annotation);\n\n        for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {\n          System.out.println(sentence);","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/SentimentPipeline.java#L318-L354","documentation":"main counts how many of the mutually exclusive input sources (-file, -fileList, -stdin) were specified and throws IllegalArgumentException if more than one is set. Exactly one input source must be chosen for the pipeline to know where to read trees from.","triggerScenarios":"Invoking SentimentPipeline with two or more of -file, -fileList, -stdin together, e.g. '-file a.txt -stdin' or '-file a.txt -fileList list.txt'.","commonSituations":"Scripts that default to -stdin but append -file when a path is provided; template commands that already contain one flag to which users add another; CI wrappers exporting both a file list and piping stdin.","solutions":["Remove all but one of -file, -fileList, -stdin from the command line.","If the goal is to process multiple files, use -fileList with a file containing the list instead of multiple -file flags.","In scripts, make the input-source selection exclusive (if/else) rather than appending flags conditionally.","Note the companion error: specifying none of them throws 'Please specify either -file, -fileList or -stdin', so always supply exactly one."],"exampleFix":"// before\njava edu.stanford.nlp.sentiment.SentimentPipeline -model model.ser.gz -file in.txt -stdin\n// after\njava edu.stanford.nlp.sentiment.SentimentPipeline -model model.ser.gz -file in.txt","handlingStrategy":"validation","validationCode":"int sources = (file != null ? 1 : 0) + (fileList != null ? 1 : 0) + (stdin ? 1 : 0);\nif (sources != 1) {\n  throw new IllegalArgumentException(\"Exactly one of -file, -fileList, -stdin must be set (got \" + sources + \")\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  SentimentPipeline.main(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"only specify one of\")) {\n    System.err.println(\"Pass exactly one input source: -file <path>, -fileList <list>, or -stdin\");\n  } else throw e;\n}","preventionTips":["In scripts, build the input flags with an if/else so only one source is ever appended.","Use -fileList for multiple files instead of combining flags.","Validate that neither -file nor -fileList is set when stdin is piped.","Also ensure at least one source is present, otherwise the sibling error fires."],"tags":["java","cli","conflicting-options","nlp"],"backgroundTag":"mutually-exclusive-flags","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"}