{"record":{"id":"3285c31872da7f0c","repo":"stanfordnlp/CoreNLP","slug":"cannot-make-an-editnode-with-no-nodename","errorCode":null,"errorMessage":"Cannot make an EditNode with no nodeName","messagePattern":"Cannot make an EditNode with no nodeName","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/EditNode.java","lineNumber":34,"sourceCode":"import edu.stanford.nlp.trees.ud.CoNLLUFeatures;\n\n/**\n * Edit an existing node to have new attributes.\n *\n * @author John Bauer\n */\npublic class EditNode extends SsurgeonEdit {\n  public static final String LABEL = \"editNode\";\n\n  final String nodeName;\n  final List<String> removedAttributes;\n  final List<String> removedMorpho;\n  final Map<String, String> attributes;\n  final Map<String, String> updateMorphoFeatures;\n\n  public EditNode(String nodeName, Map<String, String> attributes, String updateMorphoFeatures, List<String> removedAttributes, List<String> removedMorpho) {\n    if (nodeName == null) {\n      throw new SsurgeonParseException(\"Cannot make an EditNode with no nodeName\");\n    }\n    if (attributes.size() == 0 && updateMorphoFeatures == null && removedAttributes.size() == 0 && removedMorpho.size() == 0) {\n      throw new SsurgeonParseException(\"Cannot make an EditNode with no updated attributes, removed attributes, or updated/removed morphological features\");\n    }\n    AddDep.checkIllegalAttributes(attributes);\n    this.nodeName = nodeName;\n    this.attributes = new TreeMap<>(attributes);\n    if (updateMorphoFeatures != null) {\n      this.updateMorphoFeatures = new CoNLLUFeatures(updateMorphoFeatures);\n    } else {\n      this.updateMorphoFeatures = Collections.emptyMap();\n    }\n    this.removedAttributes = new ArrayList<>(removedAttributes);\n    for (String attr : removedAttributes) {\n      if (AnnotationLookup.toCoreKey(attr) == null) {\n        throw new SsurgeonParseException(\"Unknown attribute |\" + attr + \"| when building an EditNode operation\");\n      }\n    }","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/EditNode.java#L16-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide the name of a node from the semgrex match pattern as nodeName.","Ensure the -node argument is present in the editnode instruction.","Validate that the referenced node name actually appears in the preceding semgrex pattern before constructing the operation."],"exampleFix":"// before\nString node = null; // -node argument missing in rule\nnew EditNode(node, attrs, null, List.of(), List.of());\n\n// after\nString node = \"verb\"; // name of a node matched by the semgrex pattern\nnew EditNode(node, attrs, null, List.of(), List.of());","handlingStrategy":"validation","validationCode":"// Java\nif (nodeName == null || nodeName.isBlank()) {\n  throw new IllegalArgumentException(\"editnode requires a -node argument naming a matched node\");\n}","typeGuard":"// Java\nstatic boolean hasNodeName(String nodeName) {\n  return nodeName != null && !nodeName.isBlank();\n}","tryCatchPattern":"// Java\ntry {\n  EditNode op = new EditNode(nodeName, attrs, morpho, removedAttrs, removedMorpho);\n} catch (SsurgeonParseException e) {\n  log.severe(\"Invalid editnode rule: \" + e.getMessage());\n}","preventionTips":["Verify the -node argument exists in every editnode line of .ssurgeon files.","Check that nodeName appears in the preceding semgrex pattern."],"tags":["java","ssurgeon","null-check","validation"],"backgroundTag":"null-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}