stanfordnlp/CoreNLP · error · IllegalArgumentException

No conditions!

Error message

No conditions!

What it means

CaseExpression builds a chain of IfExpressions from its condition/action pairs; with zero conditions there is nothing to test and no valid chain, so the constructor eagerly rejects it with an IllegalArgumentException. This is a fail-fast guard against constructing a degenerate case expression.

Solutions

  1. Add at least one condition/action pair to the CASE expression in your rule
  2. Validate the condition list size > 0 before constructing CaseExpression
  3. If generating rules programmatically, skip creating the CaseExpression when the list is empty and use the elseExpr directly

Example fix

// before
Expression e = new Expressions.CaseExpression(conds, elseExpr); // conds is empty
// after
Expression e = conds.isEmpty() ? elseExpr : new Expressions.CaseExpression(conds, elseExpr);
Defensive patterns

Strategy: validation

Validate before calling

if (conds == null || conds.isEmpty()) {
    throw new IllegalArgumentException("CaseExpression requires at least one condition");
}
new Expressions.CaseExpression(conds, elseExpr);

Type guard

boolean hasConditions(List<Pair<Expression,Expression>> conds) {
    return conds != null && !conds.isEmpty();
}

Try / catch

try {
    Expression e = new Expressions.CaseExpression(conds, elseExpr);
} catch (IllegalArgumentException e) {
    if (e.getMessage().equals("No conditions!")) {
        e = elseExpr; // degrade gracefully
    } else throw e;
}

Prevention

When it happens

Trigger: Calling `new CaseExpression(Collections.emptyList(), elseExpr)` — typically when a parser assembles a `CASE ... END` expression and the rule text contained no `WHEN`/condition branches (only an else, or nothing at all).

Common situations: A TokensRegex rule file with a CASE expression missing all its condition clauses, often due to a typo, an accidental comment-out of the conditions, or a generator producing empty condition lists.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/1d799611fb3eb741. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java:754

      this.trueExpr = vt;
      this.falseExpr = vf;
    }

    public Value evaluate(Env env, Object... args) {
      Value condValue = condExpr.evaluate(env, args);
      Boolean cond = (Boolean) condValue.get();
      if (cond) {
        return trueExpr.evaluate(env, args);
      } else {
        return falseExpr.evaluate(env, args);
      }
    }
  }

  public static class CaseExpression extends Expressions.WrappedExpression {
    public CaseExpression(List<Pair<Expression,Expression>> conds, Expression elseExpr) {
      if (conds.size() == 0) {
        throw new IllegalArgumentException("No conditions!");
      } else {
        expr = elseExpr;
        for (int i = conds.size()-1; i>=0; i--) {
          Pair<Expression,Expression> p = conds.get(i);
          expr = new IfExpression(p.first(), p.second(), expr);
        }
      }
    }
  }


  public static class ConditionalExpression extends Expressions.WrappedExpression {

    public ConditionalExpression(Expression expr) {
      this.expr = expr;
    }

    public ConditionalExpression(String op, Expression expr1, Expression expr2) {

View on GitHub (pinned to 1b7edd19c4)