{"record":{"id":"7d89769549cac492","repo":"stanfordnlp/CoreNLP","slug":"unable-to-process-node-attribute-keys-for-ssurgeon","errorCode":null,"errorMessage":"Unable to process node attribute keys for Ssurgeon operation","messagePattern":"Unable to process node attribute keys for Ssurgeon operation","errorType":"exception","errorClass":"SsurgeonParseException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/AddDep.java","lineNumber":169,"sourceCode":"   * Certain attributes cannot be edited, especially docid, sentid, idx,\n   * or they mess up the hashmaps in the SemanticGraph\n   */\n  public static void checkIllegalAttributes(Map<String, String> attributes) {\n    if (attributes.containsKey(\"idx\")) {\n      throw new SsurgeonParseException(\"Cannot manually set the index attribute.  If you need a moveWord operation, please file an issue on github.\");\n    }\n    if (attributes.containsKey(\"sentIndex\")) {\n      throw new SsurgeonParseException(\"Cannot manually change the sentence index.  If you need an operation to change an entire sentence's sentIndex, please file an issue on github.\");\n    }\n    if (attributes.containsKey(\"docID\")) {\n      throw new SsurgeonParseException(\"Cannot manually change a document ID.  If you need an operation to change an entire sentence's document ID, please file an issue on github.\");\n    }\n\n    // if there's an exception, we'll barf when creating the pattern rather than at runtime\n    try {\n      CoreLabel newNodeObj = fromCheapStrings(attributes);\n    } catch (UnsupportedOperationException e) {\n      throw new SsurgeonParseException(\"Unable to process node attribute keys for Ssurgeon operation\", e);\n    }\n  }\n\n  /**\n   * Given the keys and values of the CoreAnnotation attributes,\n   * build a CoreLabel to use as the new word\n   */\n  public static CoreLabel fromCheapStrings(Map<String, String> attributes) {\n    String[] keys = new String[attributes.size()];\n    String[] values = new String[attributes.size()];\n    int idx = 0;\n    for (String key : attributes.keySet()) {\n      String value = attributes.get(key);\n      keys[idx] = key;\n      values[idx] = value;\n      ++idx;\n    }\n    final CoreLabel newWord = new CoreLabel(keys, values);","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/semgraph/semgrex/ssurgeon/AddDep.java#L151-L187","documentation":"After the key checks, checkIllegalAttributes performs a dry run of fromCheapStrings(attributes) to validate that every attribute key/value can actually build a CoreLabel. If that helper signals an UnsupportedOperationException, the error is rewrapped as SsurgeonParseException with this message, so malformed or unknown node attribute keys fail early at pattern-construction time rather than at runtime.","triggerScenarios":"Passing an attributes map to AddDep where a key is not a recognized CoreAnnotation key (or a value cannot be converted, e.g. non-numeric value for a numeric annotation), so AddDep.fromCheapStrings throws UnsupportedOperationException which is wrapped by this error.","commonSituations":"Typos in attribute names in .ssurgeon files (e.g. \"lamma\" instead of \"lemma\"); using CoNLL-U column names that do not map to CoreAnnotations; supplying values of the wrong type for typed annotations.","solutions":["Check the wrapped UnsupportedOperationException's cause message to find the offending key.","Correct the attribute key spelling / use only keys supported by AnnotationLookup.toCoreKey.","Validate the map by calling AddDep.checkIllegalAttributes (or fromCheapStrings) in a try-catch during script loading to fail fast with a clear message."],"exampleFix":"// before (ssurgeon rule)\naddedep -node AddDep -dep rel -attributes {lamma=dog}\n\n// after\naddedep -node AddDep -dep rel -attributes {lemma=dog}","handlingStrategy":"try-catch","validationCode":"// Java\nfor (String key : attributes.keySet()) {\n  if (AnnotationLookup.toCoreKey(key) == null) {\n    throw new IllegalArgumentException(\"Unknown attribute key: \" + key);\n  }\n}","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n  AddDep.checkIllegalAttributes(attrs);\n} catch (SsurgeonParseException e) {\n  Throwable cause = e.getCause(); // UnsupportedOperationException names the bad key/value\n  log.severe(\"Bad node attribute: \" + (cause != null ? cause.getMessage() : e.getMessage()));\n}","preventionTips":["Spell attribute keys exactly as AnnotationLookup expects; verify against the CoreNLP docs.","Run checkIllegalAttributes on every rule at load time to fail fast instead of at runtime."],"tags":["java","ssurgeon","validation","attribute-parse"],"backgroundTag":"invalid-argument-format","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"}