stanfordnlp/CoreNLP · error · SsurgeonParseException
No relation given for an AddDep
Error message
No relation given for an AddDep
What it means
AddDep requires a GrammaticalRelation for the new dependency edge; a null relation cannot produce a valid SemanticGraphEdge, so the constructor throws this SsurgeonParseException after the governor check.
Solutions
- Pass a valid GrammaticalRelation instance (e.g. GrammaticalRelation.valueOf / the appropriate UniversalEnglishGrammaticalRelations constant).
- If starting from a string, resolve it explicitly and fail early with a clear message when valueOf returns/throws for an unknown relation.
- Fix the Ssurgeon rule so its relation attribute is present and spelled exactly as a valid UD relation.
- When auditing AddDep call sites, validate govNodeName, relation, and position together — the constructor checks all three.
Example fix
// before
new AddDep("gov", null, attrs, "+1"); // throws
// after
GrammaticalRelation rel = UniversalEnglishGrammaticalRelations.NOMINAL_SUBJECT;
new AddDep("gov", rel, attrs, "+1"); Defensive patterns
Strategy: validation
Validate before calling
if (relation == null) throw new IllegalArgumentException("AddDep requires a GrammaticalRelation"); Try / catch
try { new AddDep(gov, rel, attrs, pos); } catch (SsurgeonParseException e) { throw new IllegalArgumentException("AddDep missing relation", e); } Prevention
- Resolve relation strings to GrammaticalRelation explicitly and fail early on unknowns
- Validate rule XML relation attribute against the supported UD relation set
- Check gov, relation, and position in one validation pass before construction
When it happens
Trigger: Calling new AddDep(govNodeName, null, attributes, position[, weight]); also occurs when Ssurgeon rule parsing builds an AddDep element with a missing or unrecognized relation attribute that resolves to null.
Common situations: Rule files missing the relation attribute; a relation string that failed to map to a GrammaticalRelation (e.g. not resolvable via UniversalSemanticGraphConverter/EnglishGrammaticalRelations); programmatic rule generation leaving relation unset.
Related errors
- No governor given for an AddDep
- Unknown position in AddDep operation
- ReattachNamedEdge created with no edge name!
- ReattachNamedEdge created with both gov and dep missing!
- RelabelNamedEdge created with no edge name!
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/30b4088234ba1793.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/AddDep.java:46
final String govNodeName;
final String position;
final double weight;
public AddDep(String govNodeName, GrammaticalRelation relation, Map<String, String> attributes, String position) {
this(govNodeName, relation, attributes, position, 0.0);
}
public AddDep(String govNodeName, GrammaticalRelation relation, Map<String, String> attributes, String position, double weight) {
if (position != null) {
if (!position.startsWith("-") && !position.startsWith("+")) {
throw new SsurgeonParseException("Unknown position " + position + " in AddDep operation");
}
}
if (govNodeName == null) {
throw new SsurgeonParseException("No governor given for an AddDep");
}
if (relation == null) {
throw new SsurgeonParseException("No relation given for an AddDep");
}
checkIllegalAttributes(attributes);
this.attributes = new TreeMap<>(attributes);
this.relation = relation;
this.govNodeName = govNodeName;
this.position = position;
this.weight = weight;
}
/**
* Emits a parseable instruction string.
*/
@Override
public String toEditString() {
StringWriter buf = new StringWriter();
buf.write(LABEL); buf.write("\t");
buf.write(Ssurgeon.GOV_NODENAME_ARG);buf.write(" ");View on GitHub (pinned to 1b7edd19c4)