{"record":{"id":"97fc16946f2e411c","repo":"stanfordnlp/CoreNLP","slug":"unknown-language-language-97fc16","errorCode":null,"errorMessage":"Unknown language <language>","messagePattern":"Unknown language <language>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/trees/GrammaticalRelation.java","lineNumber":618,"sourceCode":"          case \"nmod\":\n            return UniversalEnglishGrammaticalRelations.getNmod(specific);\n          case \"acl\":\n            return UniversalEnglishGrammaticalRelations.getAcl(specific);\n          case \"advcl\":\n            return UniversalEnglishGrammaticalRelations.getAdvcl(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);\n        }\n      } else {\n        return rel;\n      }\n\n    default: {\n      throw new RuntimeException(\"Unknown language \" + language);\n    }\n    }\n  }\n\n  /**\n   * Returns the parent of this {@code GrammaticalRelation}.\n   */\n  public GrammaticalRelation getParent() {\n    return parent;\n  }\n\n  public static void main(String[] args) {\n    final String[] names = {\"dep\", \"pred\", \"prep_to\",\"rcmod\"};\n    for (String name : names) {\n      GrammaticalRelation reln = valueOf(Language.English, name);\n      System.out.println(\"Data for GrammaticalRelation loaded as valueOf(\\\"\" + name + \"\\\"):\");\n      System.out.println(\"\\tShort name:    \" + reln.getShortName());\n      System.out.println(\"\\tLong name:     \" + reln.getLongName());","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/trees/GrammaticalRelation.java#L600-L636","documentation":"readResolve() switches on the GrammaticalRelation's language to find the canonical instance for that language. The switch only handles the languages the library knows; any other value falls into the default branch and throws this RuntimeException, meaning the deserialized relation carries a language the code cannot resolve.","triggerScenarios":"Deserializing a GrammaticalRelation whose language field is null or a value outside the handled enum cases (e.g. a Language constant from a different library version, or a stream corrupted so the field is wrong).","commonSituations":"Cross-version deserialization where the Language enum gained/lost constants; manually constructing/serializing a relation with an unhandled language; classloader conflicts yielding a mismatched Language enum.","solutions":["Ensure the relation's language is one supported by this CoreNLP version (e.g. English, Chinese, UniversalEnglish...) before serializing","Re-serialize with matching CoreNLP versions on both ends","Inspect the stream for corruption if language is unexpectedly null/garbage","Use the string-based GrammaticalRelations.valueOf(language, name) API with an explicit valid language instead of raw serialization"],"exampleFix":"// before\nGrammaticalRelation r = new GrammaticalRelation(someForeignLanguage, \"dep\", ...); // then serialized\n// after\nGrammaticalRelation r = new GrammaticalRelation(Language.English, \"dep\", ...);","handlingStrategy":"try-catch","validationCode":"if (language == null || !supportedLanguages.contains(language)) {\n    throw new IllegalArgumentException(\"Unsupported language for GrammaticalRelation: \" + language);\n}","typeGuard":null,"tryCatchPattern":"try {\n    GrammaticalRelation r = (GrammaticalRelation) in.readObject();\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Unknown language\")) {\n        // rebuild relation with an explicitly supported Language constant\n    } else throw e;\n}","preventionTips":["Only use Language constants from the CoreNLP version in use","Avoid hand-serializing GrammaticalRelation objects","Pin CoreNLP versions across services sharing serialized data","Convert relations to (language, name) string pairs for storage"],"tags":["java","serialization","language","switch-default"],"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-17T15:17:12.973Z"}