{"record":{"id":"86e4c852e30aa9e7","repo":"pentaho/pentaho-kettle","slug":"the-function-call-getfiscaldate-requires-2-arguments","errorCode":null,"errorMessage":"The function call getFiscalDate requires 2 arguments.","messagePattern":"The function call getFiscalDate requires 2 arguments\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":239,"sourceCode":"        Calendar startDate = Calendar.getInstance();\n        Calendar fisStartDate = Calendar.getInstance();\n        Calendar fisOffsetDate = Calendar.getInstance();\n        startDate.setTime( dIn );\n        Format dfFormatter = new SimpleDateFormat( \"dd.MM.yyyy\" );\n        String strOffsetDate = (String) ArgList[1] + String.valueOf( startDate.get( Calendar.YEAR ) );\n        java.util.Date dOffset = (java.util.Date) dfFormatter.parseObject( strOffsetDate );\n        fisOffsetDate.setTime( dOffset );\n\n        String strFisStartDate = \"01.01.\" + String.valueOf( startDate.get( Calendar.YEAR ) + 1 );\n        fisStartDate.setTime( (java.util.Date) dfFormatter.parseObject( strFisStartDate ) );\n        int iDaysToAdd = (int) ( ( startDate.getTimeInMillis() - fisOffsetDate.getTimeInMillis() ) / 86400000 );\n        fisStartDate.add( Calendar.DATE, iDaysToAdd );\n        return fisStartDate.getTime();\n      } catch ( Exception e ) {\n        throw new RuntimeException( e.toString() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call getFiscalDate requires 2 arguments.\" );\n    }\n\n  }\n\n  public static double getProcessCount( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n\n    if ( ArgList.length == 1 ) {\n      try {\n        Object scmO = actualObject.get( \"_step_\" );\n        ScriptInterface scm = (ScriptInterface) scmO;\n        String strType = ( (String) ArgList[0] ).toLowerCase();\n\n        if ( strType.equals( \"i\" ) ) {\n          return scm.getLinesInput();\n        } else if ( strType.equals( \"o\" ) ) {\n          return scm.getLinesOutput();\n        } else if ( strType.equals( \"r\" ) ) {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L221-L257","documentation":"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.","triggerScenarios":"Calling getFiscalDate(date) with only the date, or with 3+ arguments, in a Script step.","commonSituations":"Forgetting the days-to-add parameter after refactoring; passing extra fiscal-calendar config values as additional arguments.","solutions":["Call with exactly two arguments: the date and the days offset","Move extra configuration into JS variables, not function args","Default the offset in JS before calling"],"exampleFix":"// before\nvar d = getFiscalDate(today);\n// after\nvar d = getFiscalDate(today, 45);","handlingStrategy":"validation","validationCode":"// JS in Script step\nif (arguments.length !== 2) {\n  throw new Error('getFiscalDate expects (date, daysOffset)');\n}\nvar d = getFiscalDate(baseDate, days);","typeGuard":"// JS\nfunction isPair(args) {\n  return args.length === 2;\n}","tryCatchPattern":"try {\n  var d = getFiscalDate(base, days);\n} catch (e) {\n  Logger.logError('getFiscalDate failed: ' + e.message);\n  d = null;\n}","preventionTips":["Always supply both date and day-offset arguments","Keep fiscal-calendar constants in JS variables, not extra arguments","Verify signatures via the Script step's function list"],"tags":["kettle","javascript","arity","date"],"backgroundTag":"missing-required-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}