{"record":{"id":"f9873eb0d7fedb7b","repo":"stanfordnlp/CoreNLP","slug":"unknown-outputformat","errorCode":null,"errorMessage":"Unknown outputFormat: ","messagePattern":"Unknown outputFormat: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/wordseg/Sighan2005DocumentReaderAndWriter.java","lineNumber":375,"sourceCode":"      }\n      pw.print(\"\\t_\\t_\");\n      pw.println();\n    }\n\n    pw.println();\n  }\n\n  @Override\n  public void printAnswers(List<CoreLabel> doc, PrintWriter pw) {\n    switch (outputFormat) {\n    case PLAINTEXT:\n      printPlainTextAnswer(doc, pw);\n      break;\n    case CONLLU:\n      printConlluAnswer(doc, pw);\n      break;\n    default:\n      throw new IllegalArgumentException(\"Unknown outputFormat: \" + outputFormat);\n    }\n  }\n\n\n  private static String intern(String s) {\n    return s.trim().intern();\n  }\n\n  @Override\n  public void printLattice(DFSA<String, Integer> tagLattice, List<CoreLabel> doc, PrintWriter out) {\n    CoreLabel[] docArray = doc.toArray(new CoreLabel[doc.size()]);\n    // Create answer lattice:\n    MutableInteger nodeId = new MutableInteger(0);\n    DFSA<String, Integer> answerLattice = new DFSA<>(null);\n    DFSAState<String, Integer> aInitState = new DFSAState<>(nodeId.intValue(), answerLattice);\n    answerLattice.setInitialState(aInitState);\n    Map<DFSAState<String, Integer>,DFSAState<String, Integer>> stateLinks = Generics.newHashMap();\n    // Convert binary lattice into word lattice:","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/wordseg/Sighan2005DocumentReaderAndWriter.java#L357-L393","documentation":"Sighan2005DocumentReaderAndWriter.printAnswers switches on the configured outputFormat when writing segmentation answers. Hitting the default branch means the OutputFormat enum value isn't one of the handled cases, so IllegalArgumentException('Unknown outputFormat: ...') is thrown.","triggerScenarios":"Running the Sighan2005 test/writer main with an outputFormat set to an enum value not handled by the switch (e.g. a newly added OutputFormat constant not covered here).","commonSituations":"Adding a new OutputFormat to the enum without updating printAnswers; misconfigured properties mapping to an unhandled format; running main directly with a format the writer never supported.","solutions":["Set outputFormat to a supported value (e.g. the plain-text or CoNLL-U handled cases)","Add a case for the new OutputFormat in printAnswers before using it","Check which OutputFormat values printAnswers supports and align configuration"],"exampleFix":"// before\nflags.outputFormat = OutputFormat.MY_NEW_FORMAT;\n// after\nflags.outputFormat = OutputFormat.CONLLU; // or add a case in printAnswers","handlingStrategy":"validation","validationCode":"// only run main with handled formats\nif (flags.outputFormat != OutputFormat.PLAIN_TEXT && flags.outputFormat != OutputFormat.CONLLU) {\n  flags.outputFormat = OutputFormat.CONLLU;\n}","typeGuard":null,"tryCatchPattern":"try {\n  readerAndWriter.printAnswers(doc, pw);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown outputFormat\")) {\n    flags.outputFormat = OutputFormat.CONLLU;\n    readerAndWriter.printAnswers(doc, pw);\n  } else throw e;\n}","preventionTips":["Only assign OutputFormat values handled by printAnswers' switch","When extending OutputFormat, add the corresponding case in printAnswers","Log the active outputFormat at startup to catch config drift early"],"tags":["java","segmentation","output-format","enum"],"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-17T15:17:12.973Z"}