{"record":{"id":"39dfdf18654d8dd5","repo":"stanfordnlp/CoreNLP","slug":"relation-not-handled-by-getrelation","errorCode":null,"errorMessage":"Relation  not handled by getRelation","messagePattern":"Relation  not handled by getRelation","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java","lineNumber":1508,"sourceCode":"      case \"$-\":\n        return new LEFT_IMMEDIATE_SIBLING(type, name);\n      case \"$++\":\n        return new RIGHT_SIBLING(type, name);\n      case \"$--\":\n        return new LEFT_SIBLING(type, name);\n      case \".\":\n        return new ADJACENT_RIGHT(type, name);\n      case \"..\":\n        return new RIGHT(type, name);\n      case \"-\":\n        return new ADJACENT_LEFT(type, name);\n      case \"--\":\n        return new LEFT(type, name);\n      case \"@\":\n        return new ALIGNMENT();\n      default:\n        //error\n        throw new ParseException(\"Relation \" + reln +\n            \" not handled by getRelation\");\n    }\n  }\n\n  public static GraphRelation getRelation(String reln,\n                                          String type,\n                                          int num,\n                                          String name,\n                                          String edgeName) throws ParseException {\n    if (edgeName != null) {\n      throw new ParseException(\"Relation \" + reln + \" does not allow for named edges\");\n    }\n    if (reln == null && type == null)\n      return null;\n    if (reln.equals(\">>\"))\n      return new LIMITED_GRANDPARENT(type, name, num, num);\n    else if (reln.equals(\"<<\"))\n      return new LIMITED_GRANDKID(type, name, num, num);","sourceCodeStart":1490,"sourceCodeEnd":1526,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java#L1490-L1526","documentation":"This ParseException is the default branch of the first GraphRelation.getRelation overload (String reln, String type, String name, String edgeName). It fires when the relation string passed isKnownRelation() (so it is a recognized Semgrex operator) but the switch statement finds no construction branch for it and edgeName is null. This is effectively an internal fall-through: a known relation reached the default case, meaning it was not matched by either switch in the method.","triggerScenarios":"Calling getRelation(reln, type, name, edgeName) with edgeName == null and a relation from isKnownRelation() that is not matched by either switch, e.g. due to a custom relation added to isKnownRelation() without a corresponding case in getRelation, or an inconsistent build where the two dispatch tables disagree.","commonSituations":"Custom forks or modified Stanford CoreNLP builds where isKnownRelation() was extended without updating getRelation's switch; library upgrades where new operators exist in isKnownRelation but the dispatch was not synchronized; defensive code paths reached during pattern deserialization.","solutions":["Verify the relation string is one handled by this overload; for numeric-limited relations use the (reln, type, int num, ...) overload instead.","If you modified isKnownRelation(), add a matching case to getRelation's switch or route it before the switch.","Update to a consistent CoreNLP version so isKnownRelation and getRelation agree.","Wrap pattern compilation in try-catch for ParseException and report the raw pattern to identify the offending operator."],"exampleFix":"// before (custom relation added only to isKnownRelation)\nisKnownRelation: ... || reln.equals(\">>\") ...\n// after: also add a construction branch\ncase \">>\": return new GRANDPARENT(type, name);","handlingStrategy":"try-catch","validationCode":"if (!GraphRelation.isKnownRelation(reln)) {\n  throw new IllegalArgumentException(\"Unknown relation: \" + reln);\n}","typeGuard":null,"tryCatchPattern":"try {\n  GraphRelation r = GraphRelation.getRelation(reln, type, name, edgeName);\n} catch (ParseException e) {\n  log.severe(\"Unhandled relation '\" + reln + \"' in pattern; check CoreNLP version consistency\");\n}","preventionTips":["Do not modify isKnownRelation() without updating every getRelation overload.","Pin a single CoreNLP version across the project to avoid mismatched parser internals.","Add unit tests covering every known relation through each getRelation overload."],"tags":["java","parse-exception","semgrex","unhandled-relation"],"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"}