{"record":{"id":"578fdbee71b6a9b9","repo":"stanfordnlp/CoreNLP","slug":"relation-does-not-allow-for-named-edges","errorCode":null,"errorMessage":"Relation  does not allow for named edges","messagePattern":"Relation  does not allow for named edges","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java","lineNumber":1479,"sourceCode":"    }\n    switch (reln) {\n      case \">\":\n        return new GOVERNOR(type, name, edgeName);\n      case \">++\":\n        return new GOVERNOR_RIGHT(type, name, edgeName);\n      case \">--\":\n        return new GOVERNOR_LEFT(type, name, edgeName);\n      case \"<\":\n        return new DEPENDENT(type, name, edgeName);\n      case \"<++\":\n        return new DEPENDENT_RIGHT(type, name, edgeName);\n      case \"<--\":\n        return new DEPENDENT_LEFT(type, name, edgeName);\n      case \"<>\":\n        return new CONNECTED(type, name, edgeName);\n    }\n    if (edgeName != null) {\n      throw new ParseException(\"Relation \" + reln + \" does not allow for named edges\");\n    }\n    switch (reln) {\n      case \">>\":\n        return new GRANDPARENT(type, name);\n      case \"<<\":\n        return new GRANDKID(type, name);\n      case \"==\":\n        return new EQUALS(type, name);\n      case \"$+\":\n        return new RIGHT_IMMEDIATE_SIBLING(type, name);\n      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);","sourceCodeStart":1461,"sourceCodeEnd":1497,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/GraphRelation.java#L1461-L1497","documentation":"This ParseException is thrown by GraphRelation.getRelation(String,String,String,String) in Stanford Semgrex when a named edge (edgeName, the ':name' clause of a relation) is attached to a relation that does not support edge naming. Only directional relations ('>', '<', '>++', '>--', '<++', '<--', '<>') construct relation objects that accept an edgeName; all others (grandparent, sibling, adjacency, alignment, equality) reject it. The message includes the offending relation symbol.","triggerScenarios":"Calling getRelation(reln, type, name, edgeName) with a non-null edgeName for a relation not in the first switch block, e.g. getRelation(\"<<\", null, name, \"myedge\") or getRelation(\"$+\", null, name, \"e\"). Parsing a Semgrex pattern like '<<:dep' or '.:x' where the named-edge syntax is applied to an unsupported operator.","commonSituations":"Hand-written Semgrex patterns where the user assumes every operator supports ':edgeName' annotation; programmatically built patterns in annotator pipelines that append edge names uniformly to all relations; migrating patterns between Semgrex versions where the set of named-edge-capable relations differs.","solutions":["Remove the ':edgeName' suffix from the relation in the pattern (e.g. '<<:dep' -> '<<').","Use a relation that supports named edges: '>', '<', '<>', '>++', '>--', '<++', '<--'.","If you call getRelation directly, pass null for edgeName for non-directional relations.","Check GraphRelation.isKnownRelation and the first switch in getRelation to confirm which relations accept edgeName before attaching one."],"exampleFix":"// before\nGraphRelation r = GraphRelation.getRelation(\"<<\", null, name, \"dep\"); // throws\n// after\nGraphRelation r = GraphRelation.getRelation(\"<<\", null, name, null); // or use \">\" with \"dep\"","handlingStrategy":"validation","validationCode":"boolean supportsNamedEdge(String reln) {\n  return reln.equals(\">\") || reln.equals(\"<\") || reln.equals(\"<>\")\n      || reln.equals(\">++\") || reln.equals(\">--\")\n      || reln.equals(\"<++\") || reln.equals(\"<--\");\n}\n// before calling: if (!supportsNamedEdge(reln)) edgeName = null;","typeGuard":"if (edgeName != null && !supportsNamedEdge(reln)) {\n  throw new IllegalArgumentException(\"Relation \" + reln + \" does not support named edges\");\n}","tryCatchPattern":"try {\n  GraphRelation r = GraphRelation.getRelation(reln, type, name, edgeName);\n} catch (ParseException e) {\n  if (e.getMessage().contains(\"does not allow for named edges\")) {\n    r = GraphRelation.getRelation(reln, type, name, null);\n  }\n}","preventionTips":["Only append ':name' to directional relations (>, <, <>, >++, >--, <++, <--).","Validate patterns with GraphRelation.isKnownRelation plus an edge-name capability check before compilation.","Keep a pattern linter/test corpus of all supported Semgrex operators."],"tags":["java","parse-exception","semgrex","named-edges"],"backgroundTag":"invalid-argument-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"}