{"record":{"id":"f2741e1e192c426e","repo":"stanfordnlp/CoreNLP","slug":"unknown-format","errorCode":null,"errorMessage":"Unknown format ","messagePattern":"Unknown format ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/CoreLabel.java","lineNumber":856,"sourceCode":"    case LEMMA_INDEX:\n      buf.append(lemma());\n      Integer index = this.get(CoreAnnotations.IndexAnnotation.class);\n      if (index != null) {\n        buf.append('-').append((index).intValue());\n      }\n      Integer emptyIndex = this.get(CoreAnnotations.EmptyIndexAnnotation.class);\n      if (emptyIndex != null && emptyIndex != 0) {\n        buf.append('.').append((emptyIndex).intValue());\n      }\n      break;\n    case ALL:{\n      for (Class en: this.keySet()) {\n        buf.append(';').append(en).append(':').append(this.get(en));\n      }\n      break;\n    }\n    default:\n      throw new IllegalArgumentException(\"Unknown format \" + format);\n    }\n    return buf.toString();\n  }\n\n  private static final Comparator<Class<?>> asClassComparator =\n          Comparator.comparing(Class::getName);\n\n}\n","sourceCodeStart":838,"sourceCodeEnd":865,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/CoreLabel.java#L838-L865","documentation":"CoreLabel.toString(Format format) supports only a fixed set of Format enum values (e.g. VALUE, WORD, TAG, MAP, VALUE_TAG, etc.). If a caller passes a null or unhandled format value, the switch's default branch throws IllegalArgumentException(\"Unknown format \" + format). This is a defensive guard against invalid format requests rather than a data problem.","triggerScenarios":"Calling label.toString(Format) with a Format value not covered by the switch — most commonly Format.valueOf on a typo'd name, a null Format after parsing a format string, or a Format constant from a different/newer CoreLabel.Format enum than this StanNLP version supports.","commonSituations":"Configuring an output format via a user-supplied string and passing it unvalidated to toString(Format); version skew where an older Stanford CoreNLP build lacks a newer Format enum constant that configuration references.","solutions":["Check the format string/value passed; use only constants defined in CoreLabel.OutputFormat (or AbstractMapLabel.Format) that this version supports.","Null-check or default the format: Format f = fmt == null ? Format.VALUE : fmt.","Call the no-arg toString() instead of toString(format) when you just want the value.","Upgrade Stanford CoreNLP if the desired format constant exists only in newer releases."],"exampleFix":"// before\nString s = label.toString(Format.valueOf(config.get(\"fmt\"))); // IAE if unknown/null\n// after\nString s = label.toString(\"VALUE\".equals(config.get(\"fmt\")) ? Format.VALUE : Format.VALUE);","handlingStrategy":"validation","validationCode":"// Allowed formats for CoreLabel.toString(Format)\nSet<CoreLabel.OutputFormat> allowed = EnumSet.allOf(CoreLabel.OutputFormat.class);\nif (format == null || !allowed.contains(format)) {\n  format = CoreLabel.OutputFormat.VALUE; // safe default\n}\nString s = label.toString(format);","typeGuard":"boolean isKnownFormat(CoreLabel.OutputFormat f) {\n  return f != null && EnumSet.allOf(CoreLabel.OutputFormat.class).contains(f);\n}","tryCatchPattern":"try {\n  return label.toString(format);\n} catch (IllegalArgumentException e) {\n  log.warn(\"Unknown label format \" + format + \", using VALUE\");\n  return label.toString(CoreLabel.OutputFormat.VALUE);\n}","preventionTips":["Only pass Format constants referenced directly from the enum, never valueOf of arbitrary strings.","Null-check formats parsed from configuration before calling toString(Format).","Prefer the no-arg toString() when you only need the label value.","Verify the Format constant exists in your pinned CoreNLP version; enum constants are added across releases."],"tags":["java","nlp","illegal-argument","formatting"],"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"}