pentaho/pentaho-kettle · error

The function call isWorkingDay requires 1 argument.

Error message

The function call isWorkingDay requires 1 argument.

What it means

Arity guard for isWorkingDay: the function takes exactly one java.util.Date argument and checks whether it falls Monday-Friday. Null/undefined are special-cased; only an invalid argument count triggers this throw.

Solutions

  1. Call isWorkingDay with exactly one date argument: isWorkingDay(orderDate).
  2. Handle holidays separately in script logic if needed.
  3. Ensure the argument is a Date or date-convertible value.

Example fix

// before
var work = isWorkingDay(d, holidays);
// after
var work = isWorkingDay(d) && holidays.indexOf(d.getTime()) < 0;
Defensive patterns

Strategy: validation

Validate before calling

var d = orderDate instanceof Date ? orderDate : str2date(orderDate, 'yyyy-MM-dd');
var work = isWorkingDay(d);

Type guard

function isDateArg(v){ return v instanceof Date && !isNaN(v.getTime()); }

Prevention

When it happens

Trigger: isWorkingDay() with no arguments, or two arguments (e.g. date plus a holiday calendar) in a Modified Java Script Value step.

Common situations: Assuming a second argument for a custom holiday list; testing the function without arguments; arguments removed during script editing.

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

Appendix: source

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

        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return Context.getUndefinedValue();
        } else {
          java.util.Date dIn = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
          Calendar startDate = Calendar.getInstance();
          startDate.setTime( dIn );
          if ( startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SATURDAY
            && startDate.get( Calendar.DAY_OF_WEEK ) != Calendar.SUNDAY ) {
            return Boolean.TRUE;
          }
          return Boolean.FALSE;
        }
      } catch ( Exception e ) {
        return null;
      }
    } else {
      throw Context.reportRuntimeError( "The function call isWorkingDay requires 1 argument." );
    }
  }

  @SuppressWarnings( "unused" )
  public static Object fireToDB( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {

    Object oRC = new Object();
    if ( ArgList.length == 2 ) {
      try {
        Object scmO = actualObject.get( "_step_", actualObject );
        ScriptValuesMod scm = (ScriptValuesMod) Context.jsToJava( scmO, ScriptValuesMod.class );
        String strDBName = Context.toString( ArgList[0] );
        String strSQL = Context.toString( ArgList[1] );
        DatabaseMeta ci = DatabaseMeta.findDatabase( scm.getTransMeta().getDatabases(), strDBName );
        if ( ci == null ) {
          throw Context.reportRuntimeError( "Database connection not found: " + strDBName );
        }

View on GitHub (pinned to f3058517a1)