{"record":{"id":"ecec8753ede6c3fd","repo":"stanfordnlp/CoreNLP","slug":"unknown-annotation-key","errorCode":null,"errorMessage":"Unknown annotation key: ","messagePattern":"Unknown annotation key: ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/ComplexNodePattern.java","lineNumber":132,"sourceCode":"        } else if (value.startsWith(\"==\")) {\n          Double v = Double.parseDouble(value.substring(2));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.EQ));\n        } else if (value.startsWith(\"!=\")) {\n          Double v = Double.parseDouble(value.substring(2));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.NE));\n        } else if (value.startsWith(\">\")) {\n          Double v = Double.parseDouble(value.substring(1));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.GT));\n        } else if (value.startsWith(\"<\")) {\n          Double v = Double.parseDouble(value.substring(1));\n          p.add(c, new NumericAnnotationPattern(v, NumericAnnotationPattern.CmpType.LT));\n        } else if (value.matches(\"[A-Za-z0-9_+-.]+\")) {\n          p.add(c, new StringAnnotationPattern(value, env.defaultStringMatchFlags));\n        } else {\n          throw new IllegalArgumentException(\"Invalid value \" + value + \" for key: \" + attr);\n        }\n      } else {\n        throw new IllegalArgumentException(\"Unknown annotation key: \" + attr);\n      }\n    }\n  }\n\n  public void add(K c, NodePattern pattern) {\n    annotationPatterns.add(Pair.makePair(c, pattern));\n  }\n\n  @Override\n  public boolean match(M token)\n  {\n    boolean matched = true;\n    for (Pair<K,NodePattern> entry:annotationPatterns) {\n      NodePattern annoPattern = entry.second;\n      Object anno = getter.apply(token, entry.first);\n      if (!annoPattern.match(anno)) {\n        matched = false;\n        break;","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/ComplexNodePattern.java#L114-L150","documentation":"Thrown by ComplexNodePattern.populate when the attribute key is not found in the lookup map of known annotation keys (attributes/custom parsers). The library cannot map the key to any CoreMap annotation or registered custom node pattern.","triggerScenarios":"Using a misspelled or unregistered attribute name in a TokensRegex node expression, e.g. { wrd:foo } instead of { word:foo }, or a custom key that was never registered in the environment's default keys/custom parsers.","commonSituations":"Typos in rule files, upgrading CoreNLP where a key was renamed, or forgetting to register custom annotation keys when reusing rules across projects.","solutions":["Fix the key spelling to a standard CoreMap attribute (word, tag, ner, lemma, etc.)","Register the custom key via the TokensRegex environment (env with custom attribute parsers)","Check for renamed keys after upgrading CoreNLP versions"],"exampleFix":"// before\n{ wrd:/foo/ }\n// after\n{ word:/foo/ }","handlingStrategy":"validation","validationCode":"Set<String> known = Set.of(\"word\",\"tag\",\"ner\",\"lemma\",\"normalized\"); // plus your custom keys\nif (!known.contains(key)) throw new IllegalArgumentException(\"Unknown TokensRegex attribute key: \" + key);","typeGuard":"boolean isKnownAttribute(String key, Env env) { return env.getDefaults().containsKey(key); } // register custom keys in env defaults/parsers","tryCatchPattern":"try { node = ComplexNodePattern.valueOf(attr, value, env); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unknown annotation key\")) { log.error(\"Misspelled attribute: {}\", attr); } throw e; }","preventionTips":["Validate keys against CoreMap attribute names before parsing rules","Register custom keys in the environment before loading rules","Lint rule files against a known-key list in CI"],"tags":["tokensregex","parsing","unknown-key"],"backgroundTag":"invalid-argument-value","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"}