{"record":{"id":"b4d8707d14c6108b","repo":"stanfordnlp/CoreNLP","slug":"unknown-attribute-attr-when-building-an-editn","errorCode":null,"errorMessage":"Unknown attribute |${attr}| when building an EditNode operation","messagePattern":"Unknown attribute \\|(.+?)\\| when building an EditNode operation","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/EditNode.java","lineNumber":50,"sourceCode":"  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    }\n    this.removedMorpho = new ArrayList<>(removedMorpho);\n  }\n\n\n  /**\n   * Emits a parseable instruction string.\n   */\n  @Override\n  public String toEditString() {\n    StringBuilder buf = new StringBuilder();\n    buf.append(LABEL);  buf.append(\"\\t\");\n    buf.append(Ssurgeon.NODENAME_ARG);buf.append(\" \");\n    buf.append(nodeName); buf.append(\"\\t\");\n\n    for (String key : attributes.keySet()) {\n      buf.append(\"-\");","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/EditNode.java#L32-L68","documentation":"Every name listed in removedAttributes must map to a known CoreAnnotation key via AnnotationLookup.toCoreKey. If a name is unknown, the EditNode constructor throws SsurgeonParseException naming the offending attribute, preventing silent no-op removals of unrecognized keys.","triggerScenarios":"new EditNode(\"node\", attrs, null, List.of(\"feats3\"), List.of()) where \"feats3\" (or any misspelled key like \"PoS\", \"postag\") has no CoreAnnotation mapping; thrown in the constructor loop calling AnnotationLookup.toCoreKey.","commonSituations":"Typos or legacy field names in -removeAttributes lists in .ssurgeon files; using CoNLL-U column labels that AnnotationLookup does not recognize; version differences where a key was renamed.","solutions":["Fix the attribute name to one AnnotationLookup.toCoreKey recognizes (e.g. \"pos\", \"lemma\", \"word\", \"feats\", \"ner\").","Pre-validate each removal name with AnnotationLookup.toCoreKey(attr) != null before constructing EditNode.","Check the Stanford CoreNLP AnnotationLookup key table for the correct spelling for your version."],"exampleFix":"// before\nnew EditNode(\"node\", attrs, null, List.of(\"postag\"), List.of());\n\n// after\nnew EditNode(\"node\", attrs, null, List.of(\"pos\"), List.of());","handlingStrategy":"validation","validationCode":"// Java\nfor (String attr : removedAttributes) {\n  if (AnnotationLookup.toCoreKey(attr) == null) {\n    throw new IllegalArgumentException(\"Unknown attribute for removal: \" + attr);\n  }\n}","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n  EditNode op = new EditNode(node, attrs, morpho, removedAttrs, removedMorpho);\n} catch (SsurgeonParseException e) {\n  log.severe(\"Bad removeAttributes entry: \" + e.getMessage());\n}","preventionTips":["Use exact AnnotationLookup key spellings (pos, lemma, word, feats, ner) in -removeAttributes.","Pre-validate removal names against AnnotationLookup.toCoreKey when generating rules."],"tags":["java","ssurgeon","validation","attribute-parse"],"backgroundTag":"invalid-identifier","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"}