{"record":{"id":"e96e57a7b6a8c51e","repo":"stanfordnlp/CoreNLP","slug":"no-governor-given-for-an-adddep","errorCode":null,"errorMessage":"No governor given for an AddDep","messagePattern":"No governor given for an AddDep","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/AddDep.java","lineNumber":43,"sourceCode":"  public static final String LABEL = \"addDep\";\n  final Map<String, String> attributes;\n  final GrammaticalRelation relation;\n  final String govNodeName;\n  final String position;\n  final double weight;\n\n  public AddDep(String govNodeName, GrammaticalRelation relation, Map<String, String> attributes, String position) {\n    this(govNodeName, relation, attributes, position, 0.0);\n  }\n\n  public AddDep(String govNodeName, GrammaticalRelation relation, Map<String, String> attributes, String position, double weight) {\n    if (position != null) {\n      if (!position.startsWith(\"-\") && !position.startsWith(\"+\")) {\n        throw new SsurgeonParseException(\"Unknown position \" + position + \" in AddDep operation\");\n      }\n    }\n    if (govNodeName == null) {\n      throw new SsurgeonParseException(\"No governor given for an AddDep\");\n    }\n    if (relation == null) {\n      throw new SsurgeonParseException(\"No relation given for an AddDep\");\n    }\n    checkIllegalAttributes(attributes);\n\n    this.attributes = new TreeMap<>(attributes);\n    this.relation = relation;\n    this.govNodeName = govNodeName;\n    this.position = position;\n    this.weight = weight;\n  }\n\n  /**\n   * Emits a parseable instruction string.\n   */\n  @Override\n  public String toEditString() {","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/AddDep.java#L25-L61","documentation":"AddDep's constructor requires the name of the governor node to attach the new dependent to. If govNodeName is null, it throws this SsurgeonParseException immediately, since the operation cannot know where to hang the new dependency.","triggerScenarios":"Calling new AddDep(null, relation, attributes, position[, weight]); also occurs when Ssurgeon rule parsing builds an AddDep element without the governor (e.g. missing or misspelled 'gov' attribute in the rule XML).","commonSituations":"Ssurgeon rule files missing the governor attribute; refactors renaming node variables so the referenced name becomes null; programmatic rule generation that leaves the gov argument unset.","solutions":["Pass a valid named-node reference as govNodeName — a node name assigned with '=' elsewhere in the associated Semgrex pattern.","Fix the Ssurgeon rule so the governor attribute is present and matches a node name in the pattern.","Validate rule elements (gov name non-null, matches pattern names) before constructing AddDep.","Note the next check in the constructor: relation must also be non-null, so fix both together when auditing the call."],"exampleFix":"// before\nnew AddDep(null, rel, attrs, \"+1\"); // throws\n// after\nString gov = patternNodeName; // e.g. \"gov\" from {}=gov\nnew AddDep(gov, rel, attrs, \"+1\");","handlingStrategy":"validation","validationCode":"if (govNodeName == null || govNodeName.isBlank()) throw new IllegalArgumentException(\"AddDep requires a governor node name\");","typeGuard":null,"tryCatchPattern":"try { new AddDep(gov, rel, attrs, pos); } catch (SsurgeonParseException e) { throw new IllegalArgumentException(\"AddDep missing governor\", e); }","preventionTips":["Ensure the gov name matches a node named with '=' in the paired Semgrex pattern","Validate Ssurgeon rule XML for required gov attribute at load time","Fail fast in generated-rule builders when a variable is null"],"tags":["java","ssurgeon","null-argument","constructor"],"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"}