stanfordnlp/CoreNLP · error · IllegalArgumentException
Unknown output format
Error message
Unknown output format ${outputFormat} What it means
StanfordCoreNLP.getDefaultExtension maps each OutputFormat enum (JSON, XML, CONLLU, TEXT, TAGGED, INLINEXML, SERIALIZED, CUSTOM) to a file extension; a value outside the known enum constants hits the default branch and throws IllegalArgumentException. In practice this means an unrecognized/unknown outputFormat value was supplied.
Solutions
- Use one of the supported outputFormat values: json, xml, text, tagged, conllu, inlinexml, serialized, or custom.
- Correct the typo in the outputFormat property (e.g. outputFormat=text not txt).
- Align CoreNLP jar versions between producer and consumer if a new OutputFormat constant is involved.
Example fix
// before
props.setProperty("outputFormat", "txt");
// after
props.setProperty("outputFormat", "text"); Defensive patterns
Strategy: validation
Validate before calling
String fmt = props.getProperty("outputFormat", "json").toLowerCase();
List<String> allowed = Arrays.asList("json","xml","text","tagged","conllu","inlinexml","serialized","custom");
if (!allowed.contains(fmt)) throw new IllegalArgumentException("Unsupported outputFormat: " + fmt); Try / catch
try {
pipeline.processToOutputFile(...);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Unknown output format")) {
props.setProperty("outputFormat", "json"); // safe default
} else throw e;
} Prevention
- Use only documented outputFormat values: json, xml, text, tagged, conllu, inlinexml, serialized, custom.
- Lowercase the property value; don't invent formats like txt or yaml.
- Keep the CoreNLP jar version consistent across services.
When it happens
Trigger: Setting the 'outputFormat' property to an unsupported string so it fails to resolve to a known OutputFormat, or programmatically passing an OutputFormat value not handled by the switch after a library upgrade.
Common situations: Typo'd formats like outputFormat=txt (should be text) or outputFormat=yaml; using a format constant from a newer CoreNLP version with an older switch implementation.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Not a valid ellipses style:
- Not a valid quotes style:
- annotator " " requires annotation " ". The usual…
- Both parse.model and parse.executable properties must be…
- Cannot determine annotation key for
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/3e6c92a401179a36.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/StanfordCoreNLP.java:101
* @author Steven Bethard
*/
public class StanfordCoreNLP extends AnnotationPipeline {
public enum OutputFormat { TEXT, TAGGED, XML, JSON, CONLL, CONLLU, INLINEXML, SERIALIZED, CUSTOM }
private static String getDefaultExtension(OutputFormat outputFormat) {
switch (outputFormat) {
case XML: return ".xml";
case JSON: return ".json";
case CONLL: return ".conll";
case CONLLU: return ".conllu";
case TEXT: return ".out";
case TAGGED: return ".tag";
case INLINEXML: return ".inxml";
case SERIALIZED: return ".ser.gz";
case CUSTOM: return ".out";
default: throw new IllegalArgumentException("Unknown output format " + outputFormat);
}
}
/**
* An annotator name and its associated signature.
* Used in {@link #GLOBAL_ANNOTATOR_CACHE}.
*/
public static class AnnotatorSignature {
public final String name;
public final String signature;
public AnnotatorSignature(String name, String signature) {
this.name = name;
this.signature = signature;
}
@OverrideView on GitHub (pinned to 1b7edd19c4)