{"record":{"id":"fbb4466a327b1194","repo":"stanfordnlp/CoreNLP","slug":"unknown-key-key","errorCode":null,"errorMessage":"Unknown key <key>","messagePattern":"Unknown key <key>","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/CoreLabel.java","lineNumber":188,"sourceCode":"\n  public static final Map<Class<? extends GenericAnnotation<String>>, String> genericValues = Generics.newHashMap();\n\n\n  @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n  private void initFromStrings(String[] keys, String[] values) {\n    if (keys.length != values.length) {\n      throw new UnsupportedOperationException(\"Argument array lengths differ: \" +\n              Arrays.toString(keys) + \" vs. \" + Arrays.toString(values));\n    }\n    for (int i = 0; i < keys.length; i++) {\n      String key = keys[i];\n      String value = values[i];\n      Class coreKeyClass = AnnotationLookup.toCoreKey(key);\n\n      //now work with the key we got above\n      if (coreKeyClass == null) {\n        if (key != null) {\n          throw new UnsupportedOperationException(\"Unknown key \" + key);\n        }\n      } else {\n        try {\n          Class<?> valueClass = AnnotationLookup.getValueType(coreKeyClass);\n          if(valueClass.equals(String.class)) {\n            this.set(coreKeyClass, values[i]);\n          } else if(valueClass == Integer.class) {\n            this.set(coreKeyClass, Integer.parseInt(values[i]));\n          } else if(valueClass == Double.class) {\n            this.set(coreKeyClass, Double.parseDouble(values[i]));\n          } else if(valueClass == Long.class) {\n            this.set(coreKeyClass, Long.parseLong(values[i]));\n          } else if (valueClass == Boolean.class) {\n            this.set(coreKeyClass, Boolean.parseBoolean(values[i]));\n          } else if (coreKeyClass == CoreAnnotations.CoNLLUFeats.class) {\n            this.set(coreKeyClass, new CoNLLUFeatures(values[i]));\n          } else {\n            throw new UnsupportedOperationException(\"CORE: CoreLabel.initFromStrings: \" +","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/CoreLabel.java#L170-L206","documentation":"CoreLabel.initFromStrings throws UnsupportedOperationException when a key string cannot be mapped to a known CoreAnnotation class via AnnotationLookup.toCoreKey and the key is non-null. Only annotation names in the lookup table are accepted.","triggerScenarios":"Constructing CoreLabel from strings with a key like \"pos-tag\" or a custom column name that is not a registered annotation key; typos in standard keys (e.g. \"PartOfSpeach\"); feeding serialized label maps from a different CoreNLP version with renamed keys.","commonSituations":"Custom TSV/CoNLL headers not matching CoreNLP's expected key names; migrating label data between library versions where annotation names changed; hand-written key arrays using lowercase or shorthand names.","solutions":["Use exact registered key names (e.g. \"Text\", \"PartOfSpeech\", \"Lemma\", \"NamedEntityTag\", \"Word\", \"Tag\", \"Answer\").","Check the typo against AnnotationLookup's key table in the version you are using.","Pre-map custom column names to known keys before constructing the CoreLabel.","If the key is genuinely new, add a CoreAnnotation class registered in AnnotationLookup or set the value via label.set after construction."],"exampleFix":"// before\nnew CoreLabel(new String[]{\"pos\"}, new String[]{\"NN\"}); // Unknown key pos\n// after\nnew CoreLabel(new String[]{\"PartOfSpeech\"}, new String[]{\"NN\"});","handlingStrategy":"validation","validationCode":"for (String key : keys) {\n  if (key != null && AnnotationLookup.toCoreKey(key) == null) {\n    throw new IllegalArgumentException(\"Unrecognized annotation key: \" + key);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return new CoreLabel(keys, values);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unknown key\")) {\n    log.warn(\"Skipping unknown key; available keys are AnnotationLookup entries\");\n    return null; // or remap and retry\n  }\n  throw e;\n}","preventionTips":["Use exact CoreNLP key names (Text, Word, PartOfSpeech, Lemma, NamedEntityTag, Index, ...).","Maintain a mapping from your data format's column names to CoreNLP keys.","Pin the CoreNLP version and check AnnotationLookup when upgrading, since key tables can change."],"tags":["unknown-key","corelabel","annotations","parsing"],"backgroundTag":"invalid-enum-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"}