{"record":{"id":"8277784500ba4bb6","repo":"stanfordnlp/CoreNLP","slug":"invalid-feature-name","errorCode":null,"errorMessage":"Invalid feature name '","messagePattern":"Invalid feature name '","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/TregexPoweredTreebankParserParams.java","lineNumber":141,"sourceCode":"      Pair<TregexPattern, Function<TregexMatcher, String>> behavior =\n              new Pair<>(compiled, annotation.getValue().second());\n\n      annotationPatterns.put(annotation.getKey(), behavior);\n    }\n  }\n\n  /**\n   * Enable an annotation feature. If the provided feature has already\n   * been enabled, this method does nothing.\n   *\n   * @param featureName\n   * @throws java.lang.IllegalArgumentException If the provided feature\n   *           name is unknown (i.e., if there is no entry in the\n   *           {@link #annotations} collection with the same name)\n   */\n  protected void addFeature(String featureName) {\n    if (!annotations.containsKey(featureName))\n      throw new IllegalArgumentException(\"Invalid feature name '\" + featureName + \"'\");\n    if (!annotationPatterns.containsKey(featureName))\n      throw new RuntimeException(\"Compiled patterns out of sync with annotations data structure;\" +\n        \"did you call compileAnnotations?\");\n\n    features.add(featureName);\n  }\n\n  /**\n   * Disable a feature. If the feature was never enabled, this method\n   * returns without error.\n   *\n   * @param featureName\n   */\n  protected void removeFeature(String featureName) {\n    features.remove(featureName);\n  }\n\n  /**","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/TregexPoweredTreebankParserParams.java#L123-L159","documentation":"TregexPoweredTreebankParserParams.addFeature looks up the requested feature name in the static 'annotations' registry; unknown names throw IllegalArgumentException('Invalid feature name ...'). Only pre-registered annotation feature names (defined in the annotations map) may be added via -annotator style options.","triggerScenarios":"Passing an unrecognized feature name to TregexPoweredTreebankParserParams (e.g., via the -annotator option or annotate.addFeature API) that has no entry in the annotations map, or before compileAnnotations was called (which then throws the related RuntimeException).","commonSituations":"Typos in feature names in training configs, copying feature names from a different parser version where the registry changed, or calling addFeature before compileAnnotations().","solutions":["Use a feature name defined in TregexPoweredTreebankParserParams.annotations (check the source for the exact list).","Fix spelling/case of the feature name in your options file.","Call compileAnnotations() before addFeature() if wiring the params programmatically.","Verify the feature exists in your library version; upgrade/downgrade if the feature was added later."],"exampleFix":"// before\nparams.setOptionFlag(new String[]{\"-annotator\", \"SemanticHead\"}, 0);\n// after (use a registered feature name)\nparams.setOptionFlag(new String[]{\"-annotator\", \"HeadOfNp\"}, 0);","handlingStrategy":"validation","validationCode":"if (!TregexPoweredTreebankParserParams.annotations.containsKey(featureName))\n  throw new IllegalArgumentException(\"Unknown annotation feature: \" + featureName);","typeGuard":null,"tryCatchPattern":"try {\n  params.addFeature(name);\n} catch (IllegalArgumentException e) {\n  System.err.println(\"Invalid feature '\" + name + \"'; check the annotations registry in TregexPoweredTreebankParserParams\");\n}","preventionTips":["Copy feature names from the annotations map in the source of your version.","Call compileAnnotations() before addFeature() when using the API programmatically.","Keep options files and library versions aligned."],"tags":["parser-options","illegal-argument","configuration"],"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-17T15:17:12.973Z"}