{"record":{"id":"f70b27a6dcab47f4","repo":"stanfordnlp/CoreNLP","slug":"unknown-general-relation-shortname","errorCode":null,"errorMessage":"Unknown general relation <shortName>","messagePattern":"Unknown general relation <shortName>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/GrammaticalRelation.java","lineNumber":559,"sourceCode":"   *\n   * TODO: there are a bunch of things wrong with this.  For one\n   * thing, it's crazy slow, since it goes through all the existing\n   * relations in an array.  For another, it would be cleaner to have\n   * subclasses for the English and Chinese relations\n   */\n  protected Object readResolve() throws ObjectStreamException {\n    switch (language) {\n    case Any: {\n      if (shortName.equals(GOVERNOR.shortName)) {\n        return GOVERNOR;\n      } else if (shortName.equals(DEPENDENT.shortName)) {\n        return DEPENDENT;\n      } else if (shortName.equals(ROOT.shortName)) {\n        return ROOT;\n      } else if (shortName.equals(KILL.shortName)) {\n        return KILL;\n      } else {\n        throw new RuntimeException(\"Unknown general relation \" + shortName);\n      }\n    }\n    case English: {\n      GrammaticalRelation rel = EnglishGrammaticalRelations.valueOf(toString());\n      if (rel == null) {\n        switch (shortName) {\n          case \"conj\":\n            return EnglishGrammaticalRelations.getConj(specific);\n          case \"prep\":\n            return EnglishGrammaticalRelations.getPrep(specific);\n          case \"prepc\":\n            return EnglishGrammaticalRelations.getPrepC(specific);\n          default:\n            // TODO: we need to figure out what to do with relations\n            // which were serialized and then deprecated.  Perhaps there\n            // is a good way to make them singletons\n            return this;\n          //throw new RuntimeException(\"Unknown English relation \" + this);","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/GrammaticalRelation.java#L541-L577","documentation":"readResolve() reconstructs the canonical GrammaticalRelation instance after deserialization by matching the relation's shortName against the known constants for the GENERAL language case (GOVERNOR, DEPENDENT, ROOT, KILL). If the shortName matches none of them, the relation cannot be resolved and this RuntimeException is thrown — typically the result of deserializing a relation from an incompatible library version or corrupted stream.","triggerScenarios":"Deserializing a serialized GrammaticalRelation whose language is GENERAL and whose shortName is not GOVERNOR/DEPENDENT/ROOT/KILL; reading a serialization produced by a different CoreNLP version where relation names changed.","commonSituations":"Reading old serialized models/objects after upgrading Stanford CoreNLP; deserializing hand-crafted or corrupted relation objects; serializing relations across JVMs with mismatched class versions.","solutions":["Regenerate the serialized data with the same CoreNLP version that will deserialize it","Check the shortName in the stream/data for typos and correct it to a valid GENERAL relation (GOVERNOR, DEPENDENT, ROOT, KILL)","Upgrade or downgrade the CoreNLP dependency so both writer and reader use compatible relation definitions","Instead of Java serialization, persist relations as strings and rebuild them via GrammaticalRelations.valueOf/fromString"],"exampleFix":"// before\nObjectInputStream in = new ObjectInputStream(new FileInputStream(\"rels-old.ser\")); // written by CoreNLP 1.3\n// after\n// re-serialize with the current CoreNLP version, or:\nGrammaticalRelation rel = GrammaticalRelations.valueOf(Language.General, \"DEPENDENT\");","handlingStrategy":"try-catch","validationCode":"Set<String> valid = Set.of(\"GOVERNOR\",\"DEPENDENT\",\"ROOT\",\"KILL\");\nif (!valid.contains(shortName)) throw new IllegalArgumentException(\"Cannot resolve GENERAL relation: \" + shortName);","typeGuard":null,"tryCatchPattern":"try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(f))) {\n    GrammaticalRelation r = (GrammaticalRelation) in.readObject();\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Unknown general relation\")) {\n        // rebuild relation by name or re-serialize data with matching version\n    } else throw e;\n}","preventionTips":["Serialize and deserialize with the same CoreNLP version","Persist relations as name strings instead of Java serialization","Validate shortNames before serializing custom data","Keep model artifacts versioned alongside the library"],"tags":["java","serialization","deserialization","version-mismatch"],"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"}