pentaho/pentaho-kettle · error · RhinoRuntimeError

The function call isDate requires 1 argument.

Error message

The function call isDate requires 1 argument.

What it means

The isDate JavaScript function attempts Context.jsToJava(value, java.util.Date.class) and returns FALSE if the cast fails; it only throws when called with anything other than exactly 1 argument. The thrown message indicates an arity violation in the isDate call, not that the value is not a date.

Solutions

  1. Call isDate with exactly one argument
  2. Remember isDate checks convertibility to java.util.Date, not string pattern compliance — drop any format argument
  3. For string dates, parse with a Formatter/date function first, then test the result
  4. Check multiple fields with one isDate call per field

Example fix

// before
var ok = isDate(dateStr, 'yyyy-MM-dd'); // 2 args -> throws
// after
var ok = isDate(dateStr); // or parse/format the string separately
Defensive patterns

Strategy: type-guard

Validate before calling

function isDateSafe(v) {
  if (v === null || v === undefined) return false;
  return isDate(v);
}

Type guard

function isJsDate(v) { return Object.prototype.toString.call(v) === '[object Date]' && !isNaN(v.getTime()); }

Try / catch

try {
  var ok = isDate(field);
} catch (e) {
  if (e.message.indexOf('isDate requires 1 argument') >= 0) {
    // arity bug — isDate takes no format argument
  }
}

Prevention

When it happens

Trigger: isDate() with no arguments; isDate(dateValue, 'yyyy-MM-dd') — isDate takes no format argument, unlike some date helpers; passing two fields to check at once.

Common situations: Confusing isDate with other scripting languages' date-parse functions that accept a format string; attempting to validate a date string against an expected pattern in one call.

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/a2cd9a57cf9ccc47. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1509

  }

  public static Object isDate( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {

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

  public static Object decode( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    try {
      if ( ArgList.length >= 2 ) {
        if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
          return null;
        } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
          return Context.getUndefinedValue();
        }
        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)