{"record":{"id":"11874655eafd8ee8","repo":"stanfordnlp/CoreNLP","slug":"cannot-deserialize-openie-triples-with-this-method","errorCode":null,"errorMessage":"Cannot deserialize OpenIE triples with this method!","messagePattern":"Cannot deserialize OpenIE triples with this method!","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java","lineNumber":1581,"sourceCode":"    }\n    CoreMap lossySentence = fromProtoNoTokens(proto);\n    // Add tokens -- missing by default as they're populated as sublists of the document tokens\n    List<CoreLabel> tokens = proto.getTokenList().stream().map(this::fromProto).collect(Collectors.toList());\n    lossySentence.set(TokensAnnotation.class, tokens);\n    setSentenceTokenAnnotations(lossySentence, proto, tokens, null);\n    // Add entailed sentences\n    if (proto.getEntailedSentenceCount() > 0) {\n      List<SentenceFragment> entailedSentences = proto.getEntailedSentenceList().stream().map(frag -> fromProto(frag, lossySentence.get(CollapsedDependenciesAnnotation.class))).collect(Collectors.toList());\n      lossySentence.set(NaturalLogicAnnotations.EntailedSentencesAnnotation.class, entailedSentences);\n    }\n    // Add entailed clauses\n    if (proto.getEntailedClauseCount() > 0) {\n      List<SentenceFragment> entailedClauses = proto.getEntailedClauseList().stream().map(frag -> fromProto(frag, lossySentence.get(CollapsedDependenciesAnnotation.class))).collect(Collectors.toList());\n      lossySentence.set(NaturalLogicAnnotations.EntailedClausesAnnotation.class, entailedClauses);\n    }\n    // Add relation triples\n    if (proto.getOpenieTripleCount() > 0) {\n      throw new IllegalStateException(\"Cannot deserialize OpenIE triples with this method!\");\n    }\n    if (proto.getKbpTripleCount() > 0) {\n      throw new IllegalStateException(\"Cannot deserialize KBP triples with this method!\");\n    }\n    // Add chinese characters\n    if (proto.getCharacterCount() > 0) {\n      List<CoreLabel> sentenceCharacters = proto.getCharacterList().stream().map(this::fromProto).collect(Collectors.toList());\n      lossySentence.set(SegmenterCoreAnnotations.CharactersAnnotation.class, sentenceCharacters);\n    }\n    // Add text -- missing by default as it's populated from the Document\n    lossySentence.set(TextAnnotation.class, recoverOriginalText(tokens, proto));\n\n    // add section info\n    if (proto.hasSectionName())\n      lossySentence.set(SectionAnnotation.class, proto.getSectionName());\n    if (proto.hasSectionDate())\n      lossySentence.set(SectionDateAnnotation.class, proto.getSectionDate());\n    if (proto.hasSectionAuthor())","sourceCodeStart":1563,"sourceCodeEnd":1599,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java#L1563-L1599","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Serialize and deserialize the full CoreNLPProtos.Document (via fromProto(CoreNLPProtos.Document)) instead of individual Sentence protos, since triples are handled at the document path.","Remove the openie annotator from the pipeline (or strip OpenieTriple fields) before doing lossy sentence-level serialization.","Catch IllegalStateException and fall back to document-level deserialization for those sentences."],"exampleFix":"// before\nCoreNLPProtos.Sentence proto = ...;\nCoreMap sentence = serializer.fromProto(proto); // throws if openie triples present\n// after\nCoreNLPProtos.Document docProto = ...;\nAnnotation doc = serializer.fromProto(docProto); // document path supports OpenIE triples","handlingStrategy":"validation","validationCode":"if (sentenceProto.getOpenieTripleCount() > 0) {\n  throw new IllegalArgumentException(\"Sentence proto carries OpenIE triples; use document-level deserialization\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  cm = serializer.fromProto(sentenceProto);\n} catch (IllegalStateException e) {\n  cm = serializer.fromProto(documentProto).get(CoreAnnotations.SentencesAnnotation.class).get(idx);\n}","preventionTips":["Use document-level serialization whenever openie or kbp annotators are enabled","Check getOpenieTripleCount()/getKbpTripleCount() before sentence-level fromProto","Keep pipeline annotator list and serialization format decisions together in one config"],"tags":["serialization","protobuf","openie","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}