{"record":{"id":"a59aabe0f453ea93","repo":"stanfordnlp/CoreNLP","slug":"unexpected-format-outputstyle","errorCode":null,"errorMessage":"Unexpected format \" + outputStyle","messagePattern":"Unexpected format \" \\+ outputStyle","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/tagger/maxent/MaxentTagger.java","lineNumber":1502,"sourceCode":"  public void tagFromXML(InputStream input, Writer writer, String... xmlTags) {\n    OutputStyle outputStyle = OutputStyle.fromShortName(config.getOutputFormat());\n\n    TransformXML<String> txml = new TransformXML<>();\n    switch(outputStyle) {\n    case XML:\n    case INLINE_XML:\n      txml.transformXML(xmlTags, new TaggerWrapper(this),\n                        input, writer,\n                        new TransformXML.NoEscapingSAXInterface<>());\n      break;\n    case SLASH_TAGS:\n    case TSV:\n      txml.transformXML(xmlTags, new TaggerWrapper(this),\n                        input, writer,\n                        new TransformXML.SAXInterface<>());\n      break;\n    default:\n      throw new RuntimeException(\"Unexpected format \" + outputStyle);\n    }\n  }\n\n  public void tagFromXML(Reader input, Writer writer, String... xmlTags) {\n    OutputStyle outputStyle =\n      OutputStyle.fromShortName(config.getOutputFormat());\n\n    TransformXML<String> txml = new TransformXML<>();\n    switch(outputStyle) {\n    case XML:\n    case INLINE_XML:\n      txml.transformXML(xmlTags, new TaggerWrapper(this),\n                        input, writer,\n                        new TransformXML.NoEscapingSAXInterface<>());\n      break;\n    case SLASH_TAGS:\n    case TSV:\n      txml.transformXML(xmlTags, new TaggerWrapper(this),","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/tagger/maxent/MaxentTagger.java#L1484-L1520","documentation":"tagAndOutputSentence switches on the OutputStyle enum and throws a plain RuntimeException 'Unexpected format <outputStyle>' in the default branch, meaning the configured output style is not one of the implemented formats (xml, tsv, text, etc.). This usually indicates an unrecognized outputFormat config value mapped to an OutputStyle the writer cannot handle, or a new enum constant without a corresponding case.","triggerScenarios":"Config outputFormat resolving (via OutputStyle.fromShortName) to an OutputStyle with no case in tagAndOutputSentence's switch; programmatically passing an exotic OutputStyle constant.","commonSituations":"Typo or unsupported value in the outputFormat property; library version where a config value maps to an OutputStyle not handled by this method; copying an OutputStyle constant between code versions.","solutions":["Set outputFormat to a supported value: 'text', 'tsv', or 'xml'.","Check OutputStyle.fromShortName accepted names for your CoreNLP version and correct the config.","Upgrade/align CoreNLP version so config and enum handling match.","If adding a new OutputStyle, implement its case in the switch before using it."],"exampleFix":"// before\nprops.setProperty(\"outputFormat\", \"JSON\"); // unsupported -> RuntimeException\n// after\nprops.setProperty(\"outputFormat\", \"tsv\"); // or \"xml\" / \"text\"","handlingStrategy":"validation","validationCode":"java.util.Set<String> supported = java.util.Set.of(\"text\", \"tsv\", \"xml\");\nif (!supported.contains(config.getOutputFormat())) throw new IllegalArgumentException(\"Unsupported outputFormat: \" + config.getOutputFormat());","typeGuard":null,"tryCatchPattern":"try {\n  tagger.tagAndOutputSentence(sent, outputStyle, ...);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Unexpected format\")) {\n    throw new IllegalArgumentException(\"Use text/tsv/xml outputFormat\", e);\n  }\n  throw e;\n}","preventionTips":["Whitelist outputFormat to text/tsv/xml in your config loader","Check OutputStyle.fromShortName docs for accepted names","Test output config parsing at startup"],"tags":["java","runtimeexception","output-format","invalid-config"],"backgroundTag":"unsupported-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"}