{"record":{"id":"b5561e6a01ed5614","repo":"stanfordnlp/CoreNLP","slug":"invalid-number-of-arguments-to-name","errorCode":null,"errorMessage":"Invalid number of arguments to ${name}","messagePattern":"Invalid number of arguments to (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/time/GenericTimeExpressionPatterns.java","lineNumber":205,"sourceCode":"                    if (durationEnd != null) {\n                      duration = durationEnd;\n                    } else {\n                      duration = new SUTime.InexactDuration(durationUnit);\n                    }\n                  }\n                  else if (durationEnd != null) { duration = new SUTime.DurationRange(durationStart, durationEnd); }\n\n                  // Add begin and end times\n                  SUTime.Time beginTime = (in.size() > 3)? (SUTime.Time) in.get(3).get():null;\n                  SUTime.Time endTime = (in.size() > 4)? (SUTime.Time) in.get(4).get():null;\n                  SUTime.Temporal temporal = addEndPoints(duration, beginTime, endTime);\n                  if (temporal instanceof SUTime.Range) {\n                    return new Expressions.PrimitiveValue(\"RANGE\", temporal);\n                  } else {\n                    return new Expressions.PrimitiveValue(\"DURATION\", temporal);\n                  }\n                } else {\n                  throw new IllegalArgumentException(\"Invalid number of arguments to \" + name);\n                }\n              }\n            }\n    ));\n    env.bind(\"DayOfWeek\", new Expressions.PrimitiveValue<ValueFunction>(\n            Expressions.TYPE_FUNCTION,\n            new ValueFunctions.NamedValueFunction(\"DayOfWeek\") {\n              @Override\n              public boolean checkArgs(List<Value> in) {\n                if (in.size() != 1) {\n                  return false;\n                }\n                if (in.get(0) == null || !(in.get(0).get() instanceof Number)) {\n                  return false;\n                }\n                return true;\n              }\n              public Value apply(Env env, List<Value> in) {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/time/GenericTimeExpressionPatterns.java#L187-L223","documentation":"This IllegalArgumentException is thrown by the anonymous ValueFunction bound to a temporal environment function (the ISO/WEEK/DAY-family function in GenericTimeExpressionPatterns.createTemporalFunction) when its apply() is called with an argument count it does not accept. These CoreMapExpressionWrapper functions are bound into the pattern environment used by SUTime rule files, and each expects exactly the declared number of arguments; 'Invalid number of arguments to <name>' signals the arity contract was violated at expression-evaluation time.","triggerScenarios":"Calling the bound function (via a SUTime rules file expression like $func(...) or TokensRegex/env.eval) with zero arguments or more than the expected count, e.g. FUNC() or FUNC(a,b,c), so in.size() != expected inside Value.apply.","commonSituations":"Hand-edited or customized SUTime .rules/expressions files passing wrong arity; regex capture groups that produce empty or extra argument lists; programmatic Env.bind/Expressions usage calling apply() directly with a constructed List<Value> of the wrong size; pattern changes after a CoreNLP upgrade altering expected arguments.","solutions":["Count the arguments passed to the function in your SUTime rules/expressions file and pass exactly the number the function expects (check the function's binding in GenericTimeExpressionPatterns for the expected in.size()).","Check for optional/empty capture groups in the surrounding TokensRegex pattern that yield missing or extra values in the argument list.","If calling programmatically, assert in.size() matches before invoking Value.apply.","Pin/verify the Stanford CoreNLP version matches the rules-file format you are using (function arities have changed across releases)."],"exampleFix":"// before (rules file)\n$ISOSimpleDate( )\n// after\n$ISOSimpleDate( $0 )","handlingStrategy":"validation","validationCode":"if (args == null || args.size() != 1) {\n  throw new IllegalArgumentException(\"Expected exactly 1 argument, got \" + (args == null ? 0 : args.size()));\n}","typeGuard":"boolean hasValidArity(java.util.List<?> in, int expected) {\n  return in != null && in.size() == expected;\n}","tryCatchPattern":"try {\n  Value v = func.apply(env, args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Invalid number of arguments\")) {\n    // log arg count and correct the rules expression\n  } else { throw e; }\n}","preventionTips":["Match the arity documented for each bound SUTime function before editing rules files.","Keep optional capture groups out of function argument lists or flatten them explicitly.","Run SUTime rules against a small test corpus after every rules-file edit.","Pin the CoreNLP version and keep rules files in sync with it."],"tags":["java","sutime","argument-count","tokensregex"],"backgroundTag":"missing-required-argument","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}