stanfordnlp/CoreNLP · error · SsurgeonParseException

Cannot make an EditNode with no nodeName

Error message

Cannot make an EditNode with no nodeName

What it means

EditNode edits an existing matched node, so it must know which node to edit; constructing it with a null nodeName throws SsurgeonParseException immediately. The constructor also rejects edits that change nothing and delegates attribute validation to AddDep.checkIllegalAttributes.

Solutions

  1. Provide the name of a node from the semgrex match pattern as nodeName.
  2. Ensure the -node argument is present in the editnode instruction.
  3. Validate that the referenced node name actually appears in the preceding semgrex pattern before constructing the operation.

Example fix

// before
String node = null; // -node argument missing in rule
new EditNode(node, attrs, null, List.of(), List.of());

// after
String node = "verb"; // name of a node matched by the semgrex pattern
new EditNode(node, attrs, null, List.of(), List.of());
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (nodeName == null || nodeName.isBlank()) {
  throw new IllegalArgumentException("editnode requires a -node argument naming a matched node");
}

Type guard

// Java
static boolean hasNodeName(String nodeName) {
  return nodeName != null && !nodeName.isBlank();
}

Try / catch

// Java
try {
  EditNode op = new EditNode(nodeName, attrs, morpho, removedAttrs, removedMorpho);
} catch (SsurgeonParseException e) {
  log.severe("Invalid editnode rule: " + e.getMessage());
}

Prevention

When it happens

Trigger: new EditNode(null, attrs, null, [], []) — typically when the nodeName string was parsed from a rule field that is missing or empty, or generated code passes a null variable.

Common situations: Malformed editnode lines in .ssurgeon files where the -node argument is omitted; scripting tools that build EditNode from optional match-group names that failed to match.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/3285c31872da7f0c. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/EditNode.java:34

import edu.stanford.nlp.trees.ud.CoNLLUFeatures;

/**
 * Edit an existing node to have new attributes.
 *
 * @author John Bauer
 */
public class EditNode extends SsurgeonEdit {
  public static final String LABEL = "editNode";

  final String nodeName;
  final List<String> removedAttributes;
  final List<String> removedMorpho;
  final Map<String, String> attributes;
  final Map<String, String> updateMorphoFeatures;

  public EditNode(String nodeName, Map<String, String> attributes, String updateMorphoFeatures, List<String> removedAttributes, List<String> removedMorpho) {
    if (nodeName == null) {
      throw new SsurgeonParseException("Cannot make an EditNode with no nodeName");
    }
    if (attributes.size() == 0 && updateMorphoFeatures == null && removedAttributes.size() == 0 && removedMorpho.size() == 0) {
      throw new SsurgeonParseException("Cannot make an EditNode with no updated attributes, removed attributes, or updated/removed morphological features");
    }
    AddDep.checkIllegalAttributes(attributes);
    this.nodeName = nodeName;
    this.attributes = new TreeMap<>(attributes);
    if (updateMorphoFeatures != null) {
      this.updateMorphoFeatures = new CoNLLUFeatures(updateMorphoFeatures);
    } else {
      this.updateMorphoFeatures = Collections.emptyMap();
    }
    this.removedAttributes = new ArrayList<>(removedAttributes);
    for (String attr : removedAttributes) {
      if (AnnotationLookup.toCoreKey(attr) == null) {
        throw new SsurgeonParseException("Unknown attribute |" + attr + "| when building an EditNode operation");
      }
    }

View on GitHub (pinned to 1b7edd19c4)