{"record":{"id":"060f063c4c4844ba","repo":"stanfordnlp/CoreNLP","slug":"reattachnamededge-created-with-no-edge-name","errorCode":null,"errorMessage":"ReattachNamedEdge created with no edge name!","messagePattern":"ReattachNamedEdge created with no edge name!","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/ReattachNamedEdge.java","lineNumber":29,"sourceCode":" * Given a named edge, reconnect that edge elsewhere in the graph, changing either the gov and/or dep.\n *<br>\n * If an edge already exists with the new named relation,\n * <i>that</i> edge is deleted permanently.  That way, named\n * references to the first edge should still work.\n *\n * @author John Bauer\n *\n */\npublic class ReattachNamedEdge extends SsurgeonEdit {\n  public static final String LABEL = \"reattachNamedEdge\";\n\n  protected final String edgeName; // Name of the matched edge in the SemgrexPattern\n  protected final String govNodeName; // Where to put the new gov.  If null, will not edit\n  protected final String depNodeName; // Where to put the new dep.  If null, will not edit\n\n  public ReattachNamedEdge(String edgeName, String gov, String dep) {\n    if (edgeName == null) {\n      throw new SsurgeonParseException(\"ReattachNamedEdge created with no edge name!\");\n    }\n    if (gov == null && dep == null) {\n      throw new SsurgeonParseException(\"ReattachNamedEdge created with both gov and dep missing!\");\n    }\n\n    this.edgeName = edgeName;\n    this.govNodeName = gov;\n    this.depNodeName = dep;\n  }\n\n  @Override\n  public String toEditString() {\n    StringWriter buf = new StringWriter();\n    buf.write(LABEL); buf.write(\"\\t\");\n\n    buf.write(Ssurgeon.EDGE_NAME_ARG);buf.write(\" \");\n    buf.write(edgeName);\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/ReattachNamedEdge.java#L11-L47","documentation":"ReattachNamedEdge reattaches an edge that was matched and named in the SemgrexPattern to a new governor and/or dependent. It requires the name of that matched edge; if the edgeName argument is null it cannot know which edge to operate on and throws immediately in the constructor.","triggerScenarios":"Calling new ReattachNamedEdge(null, gov, dep) directly, or an Ssurgeon resource line 'reattach-named-edge' whose first argument (the named edge) is missing or empty.","commonSituations":"Hand-editing an Ssurgeon rule file and deleting the edge name token; building the operation programmatically where the edge name variable was never assigned; a malformed resource line parsed with a missing field.","solutions":["Pass the name of the edge as it is named in the SemgrexPattern (the edge: marker name) as the first argument","Check the Ssurgeon resource line: ensure the reattach-named-edge operation lists the named edge argument before gov/dep","Verify the corresponding SemgrexPattern actually names an edge with that name (edge= clause)"],"exampleFix":"// before\nnew ReattachNamedEdge(null, \"gov\", \"dep\");\n// after\nnew ReattachNamedEdge(\"myEdge\", \"gov\", \"dep\"); // 'myEdge' matches edge= in the SemgrexPattern","handlingStrategy":"validation","validationCode":"if (edgeName == null || edgeName.isEmpty()) {\n  throw new IllegalArgumentException(\"reattach-named-edge requires the name of an edge matched in the SemgrexPattern\");\n}","typeGuard":"boolean hasEdgeName(String name) { return name != null && !name.isEmpty(); }","tryCatchPattern":"try {\n  op = new ReattachNamedEdge(edgeName, gov, dep);\n} catch (SsurgeonParseException e) {\n  log.error(\"Bad Ssurgeon rule: {}\", e.getMessage());\n  throw new RuleSyntaxException(e);\n}","preventionTips":["Name edges explicitly in the SemgrexPattern with edge= and reuse that exact name","Validate Ssurgeon resource files at load time before running them","Keep gov/dep/edge arguments on one well-formed line per operation"],"tags":["java","ssurgeon","null-argument"],"backgroundTag":"null-argument","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"}