stanfordnlp/CoreNLP · error · IllegalStateException

Cannot deserialize OpenIE triples with this method!

Error message

Cannot deserialize OpenIE triples with this method!

What it means

ProtobufAnnotationSerializer.fromProto(CoreMap) refuses to deserialize sentences that carry OpenIE relation triples. The lossy per-sentence proto conversion does not support reconstructing RelationTriplesAnnotation, so the serializer treats their presence as an unsupported input rather than silently dropping data. You must use the document-level (non-lossy) deserialization path to recover OpenIE triples.

Solutions

  1. Serialize and deserialize the full CoreNLPProtos.Document (via fromProto(CoreNLPProtos.Document)) instead of individual Sentence protos, since triples are handled at the document path.
  2. Remove the openie annotator from the pipeline (or strip OpenieTriple fields) before doing lossy sentence-level serialization.
  3. Catch IllegalStateException and fall back to document-level deserialization for those sentences.

Example fix

// before
CoreNLPProtos.Sentence proto = ...;
CoreMap sentence = serializer.fromProto(proto); // throws if openie triples present
// after
CoreNLPProtos.Document docProto = ...;
Annotation doc = serializer.fromProto(docProto); // document path supports OpenIE triples
Defensive patterns

Strategy: validation

Validate before calling

if (sentenceProto.getOpenieTripleCount() > 0) {
  throw new IllegalArgumentException("Sentence proto carries OpenIE triples; use document-level deserialization");
}

Try / catch

try {
  cm = serializer.fromProto(sentenceProto);
} catch (IllegalStateException e) {
  cm = serializer.fromProto(documentProto).get(CoreAnnotations.SentencesAnnotation.class).get(idx);
}

Prevention

When it happens

Trigger: Calling ProtobufAnnotationSerializer.fromProto(CoreNLPProtos.Sentence) on a Sentence proto whose getOpenieTripleCount() > 0, e.g. a sentence round-tripped through the lossy sentence-only serialization while the annotators included openie.

Common situations: Serializing only CoreNLPProtos.Sentence objects (e.g. streaming sentence-by-sentence) from a pipeline annotated with the openie annotator, then calling fromProto on the client; or upgrading pipeline outputs to include openie while old sentence-only deserialization code remained in place.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/11874655eafd8ee8. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java:1581

    }
    CoreMap lossySentence = fromProtoNoTokens(proto);
    // Add tokens -- missing by default as they're populated as sublists of the document tokens
    List<CoreLabel> tokens = proto.getTokenList().stream().map(this::fromProto).collect(Collectors.toList());
    lossySentence.set(TokensAnnotation.class, tokens);
    setSentenceTokenAnnotations(lossySentence, proto, tokens, null);
    // Add entailed sentences
    if (proto.getEntailedSentenceCount() > 0) {
      List<SentenceFragment> entailedSentences = proto.getEntailedSentenceList().stream().map(frag -> fromProto(frag, lossySentence.get(CollapsedDependenciesAnnotation.class))).collect(Collectors.toList());
      lossySentence.set(NaturalLogicAnnotations.EntailedSentencesAnnotation.class, entailedSentences);
    }
    // Add entailed clauses
    if (proto.getEntailedClauseCount() > 0) {
      List<SentenceFragment> entailedClauses = proto.getEntailedClauseList().stream().map(frag -> fromProto(frag, lossySentence.get(CollapsedDependenciesAnnotation.class))).collect(Collectors.toList());
      lossySentence.set(NaturalLogicAnnotations.EntailedClausesAnnotation.class, entailedClauses);
    }
    // Add relation triples
    if (proto.getOpenieTripleCount() > 0) {
      throw new IllegalStateException("Cannot deserialize OpenIE triples with this method!");
    }
    if (proto.getKbpTripleCount() > 0) {
      throw new IllegalStateException("Cannot deserialize KBP triples with this method!");
    }
    // Add chinese characters
    if (proto.getCharacterCount() > 0) {
      List<CoreLabel> sentenceCharacters = proto.getCharacterList().stream().map(this::fromProto).collect(Collectors.toList());
      lossySentence.set(SegmenterCoreAnnotations.CharactersAnnotation.class, sentenceCharacters);
    }
    // Add text -- missing by default as it's populated from the Document
    lossySentence.set(TextAnnotation.class, recoverOriginalText(tokens, proto));

    // add section info
    if (proto.hasSectionName())
      lossySentence.set(SectionAnnotation.class, proto.getSectionName());
    if (proto.hasSectionDate())
      lossySentence.set(SectionDateAnnotation.class, proto.getSectionDate());
    if (proto.hasSectionAuthor())

View on GitHub (pinned to 1b7edd19c4)