stanfordnlp/CoreNLP · error · IllegalArgumentException
Invalid arguments to ${name}
Error message
Invalid arguments to ${name} What it means
GenericTimeExpressionPatterns' functional expressions (duration/time arithmetic like ISODurOperations) validate the number and types of arguments passed by the expression evaluator. When a composed expression such as a duration operation receives arguments (the `in` list) that do not match any supported arity/type combination (e.g. size 4, or wrong element types), it throws IllegalArgumentException 'Invalid arguments to <name>'.
Solutions
- Inspect which operation `name` failed and count the arguments the pattern supplies; correct the arity (supported sizes are checked in the code, e.g. 5 or 3)
- Verify each argument's expected type (numeric composite value / Number) in your custom pattern and fix non-numeric inputs
- Revert to the stock SUTime patterns file bundled with your CoreNLP version to confirm the pattern is the cause
- Upgrade/align the patterns file with your CoreNLP version — mismatched patterns are a frequent cause
Example fix
// before
// custom pattern passes 4 args to duration op
$durationOffset = ( { numcomptype:DURATION } ) (?: with ) ( { numcomptype:NUMBER } ) (?: offset ) ;
// after
// supply the supported 3- or 5-argument form
$durationOffset = ( { numcomptype:DURATION } ) (?: from ) ( { numcomptype:DURATION } ) ; Defensive patterns
Strategy: try-catch
Validate before calling
// Validate custom pattern operations against supported arities before running the pipeline
// (offline check in a unit test)
@Test
void durationOpsHaveValidArity() {
// ensure any operation invocation in the patterns file uses 3 or 5 arguments
// and that numeric operands come from numcomptype:NUMBER captures
} Type guard
// Java: verify numeric operand before invoking duration operations
static boolean validDurationOpArgs(java.util.List<Expressions.Expression> in) {
return in.size() == 3 || in.size() == 5; // supported arities
} Try / catch
try {
pipeline.annotate(annotation);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Invalid arguments to")) {
logger.severe("Bad SUTime pattern invocation: " + e.getMessage());
// fall back to stock patterns file
} else throw e;
} Prevention
- Do not hand-edit SUTime patterns without checking each functional expression's expected argument count/types
- Run a small corpus through the pipeline in CI to catch pattern regressions early
- Keep the patterns file and CoreNLP jar versions in sync
- Quote numeric operands with numcomptype:NUMBER so operations receive Number values, not Strings
When it happens
Trigger: A time expression pattern's option/functional expression calls an operation (e.g. duration offset arithmetic) with an argument list whose size or element types are unsupported — typically from a custom or edited patterns file (tokensregex/semgrex options) that invokes the operation with the wrong argument count or a non-numeric argument where a Number is expected.
Common situations: Editing the default SUTime patterns (defs/patterns) to add custom duration expressions; passing a String where a numeric composite value is expected; pattern grammar changes across CoreNLP versions making an expression emit a different argument arity.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Unknown clique: " + clique
- Unknown format
- Sentence.toSentence: lengths differ
- CoreMap must have either a Calendar or DocDate annotation
- Too many timexes for '${str}'
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/71b3290570f5d732.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/time/GenericTimeExpressionPatterns.java:166
public boolean checkArgs(List<Value> in) {
// TODO: Check args
return true;
}
public Value apply(Env env, List<Value> in) {
if (in.size() == 2) {
SUTime.Duration d = (SUTime.Duration) in.get(0).get();
if (in.get(1).get() instanceof Number) {
int m = ((Number) in.get(1).get()).intValue();
return new Expressions.PrimitiveValue("DURATION", d.multiplyBy(m));
} else if (in.get(1).get() instanceof String){
Number n = Integer.parseInt((String) in.get(1).get());
if (n != null) {
return new Expressions.PrimitiveValue("DURATION", d.multiplyBy(n.intValue()));
} else {
return null;
}
} else {
throw new IllegalArgumentException("Invalid arguments to " + name);
}
} else if (in.size() == 5 || in.size() == 3) {
// TODO: Handle Strings...
List<? extends CoreMap> durationStartTokens = (List<? extends CoreMap>) in.get(0).get();
Number durationStartVal = (durationStartTokens != null)? durationStartTokens.get(0).get(CoreAnnotations.NumericCompositeValueAnnotation.class):null;
List<? extends CoreMap> durationEndTokens = (List<? extends CoreMap>) in.get(1).get();
Number durationEndVal = (durationEndTokens != null)? durationEndTokens.get(0).get(CoreAnnotations.NumericCompositeValueAnnotation.class):null;
// TODO: This should already be in durations....
List<? extends CoreMap> durationUnitTokens = (List<? extends CoreMap>) in.get(2).get();
//String durationUnitString = (durationUnitTokens != null)? durationUnitTokens.get(0).get(CoreAnnotations.TextAnnotation.class):null;
//SUTime.Duration durationUnit = getDuration(durationUnitString);
TimeExpression te = (durationUnitTokens != null)? durationUnitTokens.get(0).get(TimeExpression.Annotation.class):null;
SUTime.Duration durationUnit = (SUTime.Duration) te.getTemporal();
// TODO: Handle inexactness
// Create duration range...
SUTime.Duration durationStart = (durationStartVal != null)? durationUnit.multiplyBy(durationStartVal.intValue()):null;
SUTime.Duration durationEnd = (durationEndVal != null)? durationUnit.multiplyBy(durationEndVal.intValue()):null;View on GitHub (pinned to 1b7edd19c4)