pentaho/pentaho-kettle · error · RuntimeException

The function call isDate requires 1 argument.

Error message

The function call isDate requires 1 argument.

What it means

isDate validates that its single argument can be evaluated as a date. If the function is called with anything other than exactly one argument, this RuntimeException is thrown rather than returning Boolean.FALSE.

Solutions

  1. Call isDate with exactly one argument.
  2. Ensure the value passed is a string/date that JavaScript's Date parsing can handle (valid dates return TRUE; unparseable values return FALSE, only wrong arity throws).
  3. Split multi-value checks into separate calls.

Example fix

// before
var ok = isDate(d1, d2); // throws
// after
var ok = isDate(d1) && isDate(d2);
Defensive patterns

Strategy: validation

Validate before calling

function safeIsDate(v) {
  return (arguments.length === 1) ? isDate(v) : false;
}

Type guard

function isDateLike(v) {
  return v instanceof Date || (typeof v === 'string' && !isNaN(Date.parse(v)));
}

Try / catch

try {
  var ok = isDate(v);
} catch (e) {
  var ok = false; // wrong arity, not an invalid date
}

Prevention

When it happens

Trigger: Calling isDate() with zero arguments, or isDate(a, b) with more than one, inside a JavaScript step.

Common situations: Same arity mistakes as isNum: stray commas, batch attempts, refactoring leftovers.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/f8b0460f4487a51e. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1474

  }

  public static Object isDate( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {

    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return undefinedValue;
        }
        /* java.util.Date d = (java.util.Date) */
        return Boolean.TRUE;
      } catch ( Exception e ) {
        return Boolean.FALSE;
      }
    } else {
      throw new RuntimeException( "The function call isDate requires 1 argument." );
    }
  }

  public static Object decode( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    try {
      if ( ArgList.length >= 2 ) {
        if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
          return null;
        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
          return undefinedValue;
        }
        Object objToCompare = ArgList[0];
        for ( int i = 1; i < ArgList.length - 1; i = i + 2 ) {
          if ( ArgList[i].equals( objToCompare ) ) {
            return ArgList[i + 1];
          }
        }

View on GitHub (pinned to f3058517a1)