{"record":{"id":"b291b60e97446387","repo":"stanfordnlp/CoreNLP","slug":"output-is-required","errorCode":null,"errorMessage":"-output is required","messagePattern":"-output is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/tools/ParseAndSetLabels.java","lineNumber":240,"sourceCode":"      } else if (args[argIndex].equalsIgnoreCase(\"-binarize\")) {\n        binarize = true;\n        argIndex += 1;\n      } else if (args[argIndex].equalsIgnoreCase(\"-nobinarize\")) {\n        binarize = false;\n        argIndex += 1;\n      } else if (args[argIndex].equalsIgnoreCase(\"-useLabelKeys\")) {\n        useLabelKeys = true;\n        argIndex += 1;\n      } else if (args[argIndex].equalsIgnoreCase(\"-nouseLabelKeys\")) {\n        useLabelKeys = false;\n        argIndex += 1;\n      } else {\n        throw new IllegalArgumentException(\"Unknown argument \" + args[argIndex]);\n      }\n    }\n\n    if (outputFile == null) {\n      throw new IllegalArgumentException(\"-output is required\");\n    }\n    if (sentencesFile == null && !useLabelKeys) {\n      throw new IllegalArgumentException(\"-sentences or -useLabelKeys is required\");\n    }\n    if (sentencesFile != null && useLabelKeys) {\n      throw new IllegalArgumentException(\"Use only one of -sentences or -useLabelKeys\");\n    }\n    if (labelsFile == null) {\n      throw new IllegalArgumentException(\"-labels is required\");\n    }\n\n    ParserGrammar parser = loadParser(parserFile, taggerFile);\n\n    TreeBinarizer binarizer = null;\n    if (binarize) {\n      binarizer = TreeBinarizer.simpleTreeBinarizer(parser.getTLPParams().headFinder(), parser.treebankLanguagePack());\n    }\n","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/tools/ParseAndSetLabels.java#L222-L258","documentation":"After flag parsing, main validates its required arguments; if -output was never provided it throws IllegalArgumentException(\"-output is required\"). The tool needs an output path for the rewritten trees, so it refuses to run without one.","triggerScenarios":"Running ParseAndSetLabels.main without the -output flag (or with a flag spelling that failed to match, leaving outputFile null).","commonSituations":"Forgotten -output in batch scripts; typo'd flag silently skipped by the unknown-argument check earlier; scripts migrated from other tools with different output flags.","solutions":["Add -output <file> to the command line","Verify the flag is spelled -output exactly (case-insensitive match only)","Ensure no earlier parse error consumed the output path token"],"exampleFix":"// before\n// java ParseAndSetLabels -parser model.ser.gz -labels labels.txt -sentences s.txt\n// after\n// java ParseAndSetLabels -parser model.ser.gz -labels labels.txt -sentences s.txt -output labeled.txt","handlingStrategy":"validation","validationCode":"if (!java.util.Arrays.asList(args).contains(\"-output\")) throw new IllegalArgumentException(\"-output is required before running\");","typeGuard":null,"tryCatchPattern":"try {\n  ParseAndSetLabels.main(args);\n} catch (IllegalArgumentException e) {\n  if (\"-output is required\".equals(e.getMessage())) System.err.println(\"Add -output <file> to the command line\");\n  throw e;\n}","preventionTips":["Validate CLI flags in wrapper scripts before invoking","Keep a canonical command template with all required flags","Check the exit message names the exact missing flag"],"tags":["java","cli","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}