{"record":{"id":"d08ad4bf10172cd6","repo":"stanfordnlp/CoreNLP","slug":"unknown-format-d08ad4","errorCode":null,"errorMessage":"Unknown format ","messagePattern":"Unknown format ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/sentiment/SentimentPipeline.java","lineNumber":240,"sourceCode":"      } else {\n        MemoryTreebank treebank = new MemoryTreebank(\"utf-8\");\n        treebank.loadPath(filename, null);\n        trees = new ArrayList<>(treebank);\n      }\n\n      List<Annotation> annotations = Generics.newArrayList();\n      for (Tree tree : trees) {\n        CoreMap sentence = new Annotation(SentenceUtils.listToString(tree.yield()));\n        sentence.set(TreeCoreAnnotations.TreeAnnotation.class, tree);\n        List<CoreMap> sentences = Collections.singletonList(sentence);\n        Annotation annotation = new Annotation(\"\");\n        annotation.set(CoreAnnotations.SentencesAnnotation.class, sentences);\n        annotations.add(annotation);\n      }\n      return annotations;\n    }\n    default:\n      throw new IllegalArgumentException(\"Unknown format \" + inputFormat);\n    }\n  }\n\n  /** Runs the tree-based sentiment model on some text. */\n  public static void main(String[] args) throws IOException {\n    String parserModel = null;\n    String sentimentModel = null;\n\n    String filename = null;\n    String fileList = null;\n    boolean stdin = false;\n\n    boolean filterUnknown = false;\n\n    List<Output> outputFormats = Collections.singletonList(Output.ROOT);\n    Input inputFormat = Input.TEXT;\n\n    String tlppClass = DEFAULT_TLPP_CLASS;","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/sentiment/SentimentPipeline.java#L222-L258","documentation":"getAnnotations builds per-sentence annotations depending on the configured input format (stdin text vs file vs tree file). If the format value doesn't match any of its recognized cases, the default branch throws IllegalArgumentException(\"Unknown format \" + inputFormat). It is an internal configuration validation on the input source mode.","triggerScenarios":"Calling getAnnotations (via annotations()) with an inputFormat value not handled by its switch, e.g. a malformed -input flag value on the command line or an enum constant added by custom code but not handled in this switch.","commonSituations":"Typo in the -input CLI value (e.g. 'trees' vs 'tree'); version drift where a newer/older SentimentPipeline recognizes different format strings; custom integrations passing their own format constants.","solutions":["Pass a supported -input format value exactly as documented (run with -help to list them).","Fix casing/spelling of the format string on the command line.","If calling programmatically, use the same enum/string constants the pipeline defines rather than free-form strings.","If extending the library, add the new format as a case in getAnnotations' switch."],"exampleFix":"// before\njava edu.stanford.nlp.sentiment.SentimentPipeline -input Trees -filelist list.txt\n// after\njava edu.stanford.nlp.sentiment.SentimentPipeline -input tree -filelist list.txt","handlingStrategy":"validation","validationCode":"Set<String> validInputs = new HashSet<>(Arrays.asList(\"stdin\", \"file\", \"tree\"));\nif (!validInputs.contains(inputArg)) {\n  throw new IllegalArgumentException(\"input must be one of \" + validInputs);\n}","typeGuard":null,"tryCatchPattern":"try {\n  SentimentPipeline.main(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown format\")) {\n    System.err.println(\"Check the -input value; run with -help for allowed formats\");\n  } else throw e;\n}","preventionTips":["Use the documented -input values verbatim (case-sensitive).","Pin the library version in build/deploy scripts so format strings stay consistent.","Prefer the pipeline's own constants/enums over hand-typed strings in programmatic use.","Run -help once per version and store the accepted values in your config."],"tags":["java","cli","invalid-option","nlp"],"backgroundTag":"invalid-enum-value","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"}