stanfordnlp/CoreNLP · error · UnsupportedOperationException
Expression was not evaluated....
Error message
Expression was not evaluated....
What it means
Expressions.MapValue stores unevaluated Expression objects per attribute. getValue(attr) only supports already-evaluated Values; if the stored expression is not a Value instance, it cannot return it and throws UnsupportedOperationException('Expression was not evaluated....').
Solutions
- Call evaluate(env, args) on the expression (or the MapValue's expressions) before calling getValue
- Use the get(String attr)/generic accessor path if it handles evaluation, instead of getValue
- Check the attribute key: expr==null returns null silently, so a wrong key is not the cause — the key exists but holds an unevaluated Expression
- If you own the code, evaluate the nested expression and store the resulting Value back into the map
Example fix
// before
Value v = mapValue.getValue("key"); // holds raw Expression
// after
Value v = (Value) expression.evaluate(env).get(); // evaluate first, or use the evaluate() API on the parent expression Defensive patterns
Strategy: type-guard
Validate before calling
Expression e = mapValue.getExpression(attr); // or via underlying map
if (e instanceof Value) {
Value v = (Value) e;
} else {
e.evaluate(env); // evaluate before getValue
} Type guard
boolean isEvaluated(Expression e) {
return e instanceof Value;
} Try / catch
try {
Value v = mapValue.getValue(attr);
} catch (UnsupportedOperationException e) {
if (e.getMessage().contains("not evaluated")) {
// run the evaluation phase, then retry
} else throw e;
} Prevention
- Always run expression.evaluate(env) before reading results via getValue
- Use the evaluate() pipeline API rather than poking at intermediate MapValue structures
- In custom walkers, check `instanceof Value` before casting expression results
When it happens
Trigger: Calling getValue(attr) on a MapValue produced from expressions that were never evaluated — e.g. reading fields of a composite expression result directly instead of calling evaluate() first, or fetching attributes whose expressions are lazy/deferred.
Common situations: Custom code walking TokensRegex expression results and calling getValue() on a nested MapValue before running the evaluation phase, or attributes created by `with`/assignment clauses that weren't evaluated.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Cannot find function matching args
- Unknown function
- Unsupported function value
- 2 arguments expected, got
- Annotation field cannot be null
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/36c4e877fe7acb3a.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java:1210
}
return ok;
}
public Set<String> getAttributes() {
return value.keySet();
}
public Expression getExpression(String attr) {
return value.get(attr);
}
public Value getValue(String attr) {
Expression expr = value.get(attr);
if (expr == null) return null;
if (expr instanceof Value) {
return (Value) expr;
}
throw new UnsupportedOperationException("Expression was not evaluated....");
}
public <T> T get(String attr) {
Expression expr = value.get(attr);
if (expr == null) return null;
if (expr instanceof Value) {
return ((Value<T>) expr).get();
}
throw new UnsupportedOperationException("Expression was not evaluated....");
}
public void set(String attr, Object obj) {
if (obj instanceof Expression) {
value.put(attr, (Expression) obj);
} else {
value.put(attr, createValue(null, obj));
}
evaluated = null;View on GitHub (pinned to 1b7edd19c4)