{"record":{"id":"bb157d2097b03d93","repo":"stanfordnlp/CoreNLP","slug":"reattachnamededge-created-with-both-gov-and-dep-mi","errorCode":null,"errorMessage":"ReattachNamedEdge created with both gov and dep missing!","messagePattern":"ReattachNamedEdge created with both gov and dep missing!","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/ReattachNamedEdge.java","lineNumber":32,"sourceCode":" * <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\n    if (govNodeName != null) {\n      buf.write(\"\\t\");\n      buf.write(Ssurgeon.GOV_NODENAME_ARG);buf.write(\" \");","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/ReattachNamedEdge.java#L14-L50","documentation":"ReattachNamedEdge must be given at least one of the new governor or the new dependent node names; if both are null the operation would reattach the edge to exactly where it already is, which is a no-op, so the constructor rejects it.","triggerScenarios":"new ReattachNamedEdge(edgeName, null, null), or an Ssurgeon resource 'reattach-named-edge' line supplying neither a -gov nor a -dep argument.","commonSituations":"Deleting the -gov or -dep token from a rule while editing it and accidentally deleting both; a rule generator emitting empty arguments; copy-paste from a relabel rule that takes neither gov nor dep.","solutions":["Supply the name of the matched node to use as the new governor (-gov) or new dependent (-dep)","If you only meant to change the relation, use a relabel-named-edge operation instead","Check the resource line so at least one of gov/dep arguments is present"],"exampleFix":"// before\nnew ReattachNamedEdge(\"myEdge\", null, null);\n// after\nnew ReattachNamedEdge(\"myEdge\", \"newGov\", null);","handlingStrategy":"validation","validationCode":"if (gov == null && dep == null) {\n  throw new IllegalArgumentException(\"reattach-named-edge needs at least one of -gov or -dep\");\n}","typeGuard":"boolean hasAtLeastOneTarget(String gov, String dep) { return gov != null || dep != null; }","tryCatchPattern":"try {\n  op = new ReattachNamedEdge(edgeName, gov, dep);\n} catch (SsurgeonParseException e) {\n  log.error(\"ReattachNamedEdge rule incomplete: {}\", e.getMessage());\n  throw new RuleSyntaxException(e);\n}","preventionTips":["If you only want to change the relation, use relabel-named-edge, not reattach-named-edge","Lint Ssurgeon rule files to require at least one of -gov/-dep on reattach operations","Keep rule edits in version control so dropped arguments are visible in diffs"],"tags":["java","ssurgeon","null-argument"],"backgroundTag":"missing-required-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"}