{"record":{"id":"1d799611fb3eb741","repo":"stanfordnlp/CoreNLP","slug":"no-conditions","errorCode":null,"errorMessage":"No conditions!","messagePattern":"No conditions!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java","lineNumber":754,"sourceCode":"      this.trueExpr = vt;\n      this.falseExpr = vf;\n    }\n\n    public Value evaluate(Env env, Object... args) {\n      Value condValue = condExpr.evaluate(env, args);\n      Boolean cond = (Boolean) condValue.get();\n      if (cond) {\n        return trueExpr.evaluate(env, args);\n      } else {\n        return falseExpr.evaluate(env, args);\n      }\n    }\n  }\n\n  public static class CaseExpression extends Expressions.WrappedExpression {\n    public CaseExpression(List<Pair<Expression,Expression>> conds, Expression elseExpr) {\n      if (conds.size() == 0) {\n        throw new IllegalArgumentException(\"No conditions!\");\n      } else {\n        expr = elseExpr;\n        for (int i = conds.size()-1; i>=0; i--) {\n          Pair<Expression,Expression> p = conds.get(i);\n          expr = new IfExpression(p.first(), p.second(), expr);\n        }\n      }\n    }\n  }\n\n\n  public static class ConditionalExpression extends Expressions.WrappedExpression {\n\n    public ConditionalExpression(Expression expr) {\n      this.expr = expr;\n    }\n\n    public ConditionalExpression(String op, Expression expr1, Expression expr2) {","sourceCodeStart":736,"sourceCodeEnd":772,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ling/tokensregex/types/Expressions.java#L736-L772","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Add at least one condition/action pair to the CASE expression in your rule","Validate the condition list size > 0 before constructing CaseExpression","If generating rules programmatically, skip creating the CaseExpression when the list is empty and use the elseExpr directly"],"exampleFix":"// before\nExpression e = new Expressions.CaseExpression(conds, elseExpr); // conds is empty\n// after\nExpression e = conds.isEmpty() ? elseExpr : new Expressions.CaseExpression(conds, elseExpr);","handlingStrategy":"validation","validationCode":"if (conds == null || conds.isEmpty()) {\n    throw new IllegalArgumentException(\"CaseExpression requires at least one condition\");\n}\nnew Expressions.CaseExpression(conds, elseExpr);","typeGuard":"boolean hasConditions(List<Pair<Expression,Expression>> conds) {\n    return conds != null && !conds.isEmpty();\n}","tryCatchPattern":"try {\n    Expression e = new Expressions.CaseExpression(conds, elseExpr);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"No conditions!\")) {\n        e = elseExpr; // degrade gracefully\n    } else throw e;\n}","preventionTips":["Lint TokensRegex rule files for CASE blocks with zero WHEN clauses","Validate rule files at load time before pipeline startup","When generating rules programmatically, assert condition lists are non-empty"],"tags":["tokensregex","expressions","illegal-argument"],"backgroundTag":"empty-required-field","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"}