pentaho/pentaho-kettle · error · RuntimeException

The function call getFiscalDate requires 2 arguments.

Error message

The function call getFiscalDate requires 2 arguments.

What it means

Arity guard in ScriptAddedFunctions.getFiscalDate: the script invocation did not pass exactly 2 arguments (a date and a fiscal-year offset string such as a month.day prefix). The function builds its fiscal calendars from ArgList[0]/ArgList[1], so any other count is rejected.

Solutions

  1. Call with exactly two arguments: the date and the days offset
  2. Move extra configuration into JS variables, not function args
  3. Default the offset in JS before calling

Example fix

// before
var d = getFiscalDate(today);
// after
var d = getFiscalDate(today, 45);
Defensive patterns

Strategy: validation

Validate before calling

// JS in Script step
if (arguments.length !== 2) {
  throw new Error('getFiscalDate expects (date, daysOffset)');
}
var d = getFiscalDate(baseDate, days);

Type guard

// JS
function isPair(args) {
  return args.length === 2;
}

Try / catch

try {
  var d = getFiscalDate(base, days);
} catch (e) {
  Logger.logError('getFiscalDate failed: ' + e.message);
  d = null;
}

Prevention

When it happens

Trigger: Calling getFiscalDate(date) with only the date, or with 3+ arguments, in a Script step.

Common situations: Forgetting the days-to-add parameter after refactoring; passing extra fiscal-calendar config values as additional arguments.

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

Appendix: source

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

        Calendar startDate = Calendar.getInstance();
        Calendar fisStartDate = Calendar.getInstance();
        Calendar fisOffsetDate = Calendar.getInstance();
        startDate.setTime( dIn );
        Format dfFormatter = new SimpleDateFormat( "dd.MM.yyyy" );
        String strOffsetDate = (String) ArgList[1] + String.valueOf( startDate.get( Calendar.YEAR ) );
        java.util.Date dOffset = (java.util.Date) dfFormatter.parseObject( strOffsetDate );
        fisOffsetDate.setTime( dOffset );

        String strFisStartDate = "01.01." + String.valueOf( startDate.get( Calendar.YEAR ) + 1 );
        fisStartDate.setTime( (java.util.Date) dfFormatter.parseObject( strFisStartDate ) );
        int iDaysToAdd = (int) ( ( startDate.getTimeInMillis() - fisOffsetDate.getTimeInMillis() ) / 86400000 );
        fisStartDate.add( Calendar.DATE, iDaysToAdd );
        return fisStartDate.getTime();
      } catch ( Exception e ) {
        throw new RuntimeException( e.toString() );
      }
    } else {
      throw new RuntimeException( "The function call getFiscalDate requires 2 arguments." );
    }

  }

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

    if ( ArgList.length == 1 ) {
      try {
        Object scmO = actualObject.get( "_step_" );
        ScriptInterface scm = (ScriptInterface) scmO;
        String strType = ( (String) ArgList[0] ).toLowerCase();

        if ( strType.equals( "i" ) ) {
          return scm.getLinesInput();
        } else if ( strType.equals( "o" ) ) {
          return scm.getLinesOutput();
        } else if ( strType.equals( "r" ) ) {

View on GitHub (pinned to f3058517a1)