stanfordnlp/CoreNLP · error · UnsupportedOperationException
Unknown null attribute.
Error message
Unknown null attribute.
What it means
In ChunkAnnotationUtils.annotateWithMatchingFields, when the attribute value is null, the code only supports setting null on keys that are handled by the primary branch; reaching the else clause means a null value was supplied for an attribute the method doesn't support, so it throws UnsupportedOperationException('Unknown null attribute.').
Solutions
- Remove null-valued entries from the attributes map before calling
- Only pass keys the method supports when the value is null
- Provide a non-null string value and let valueOf parse it
Example fix
// before
attributes.put("Tag", null);
annotateChunk(chunk, attributes);
// after
attributes.remove("Tag"); // or set a real value
annotateChunk(chunk, attributes); Defensive patterns
Strategy: validation
Validate before calling
attributes.values().removeIf(Objects::isNull); // strip null entries before annotateChunk
Type guard
static boolean hasNullValues(Map<String,String> m) {
return m.values().stream().anyMatch(Objects::isNull);
} Try / catch
try {
ChunkAnnotationUtils.annotateChunk(chunk, attributes);
} catch (UnsupportedOperationException e) {
if (e.getMessage().equals("Unknown null attribute.")) {
// remove null entries and retry
} else throw e;
} Prevention
- Never put null values in the attributes map
- Filter/omit attributes you cannot populate
When it happens
Trigger: Passing an entry with a null value in the attributes map to annotateChunk/annotateChunks for a key that is not one of the recognized null-supported annotation classes.
Common situations: Programmatic construction of the attributes map inserting null values; generic code copying properties where some are null.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unable to annotate attribute " + key
- KBestSequenceFinder only works with rightWindow == 0 not
- LogPrior.getSigmaSquaredM is undefined for any prior but…
- If you want to ask for the probability, you must train a…
- Predict not implemented for max margin
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/b9cf65f78394a08c.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/pipeline/ChunkAnnotationUtils.java:866
if (value != null) {
try {
Class valueClass = AnnotationLookup.getValueType(coreKeyClass);
if (valueClass == String.class) {
chunk.set(coreKeyClass, value);
} else {
Method valueOfMethod = valueClass.getMethod("valueOf", String.class);
if (valueOfMethod != null) {
chunk.set(coreKeyClass, valueOfMethod.invoke(valueClass, value));
}
}
} catch (Exception ex) {
throw new RuntimeException("Unable to annotate attribute " + key, ex);
}
} else {
chunk.set(coreKeyClass, null);
}
} else {
throw new UnsupportedOperationException("Unknown null attribute.");
}
}
}
public static void annotateChunks(List<? extends CoreMap> chunks, int start, int end, Map<String,String> attributes) {
for (int i = start; i < end; i++) {
annotateChunk(chunks.get(i), attributes);
}
}
public static void annotateChunks(List<? extends CoreMap> chunks, Map<String,String> attributes) {
for (CoreMap chunk:chunks) {
annotateChunk(chunk, attributes);
}
}
public static <T extends CoreMap> T createCoreMap(CoreMap cm, String text, int start, int end,
CoreTokenFactory<T> factory) {View on GitHub (pinned to 1b7edd19c4)