pentaho/pentaho-kettle · error · RuntimeException
The function call getNextWorkingDay requires 1 argument.
Error message
The function call getNextWorkingDay requires 1 argument.
What it means
ScriptAddedFunctions.getNextWorkingDay is a JavaScript-callable helper exposed to Pentaho Kettle's JavaScript step. It computes the next working day from a date argument, but only when exactly one argument is passed in ArgList. When called with zero or more than one argument it throws this RuntimeException instead of computing a result.
Solutions
- Pass exactly one argument: getNextWorkingDay(new Date()) or getNextWorkingDay(dateField).
- Check for typos or stray commas creating extra arguments in the JavaScript call.
- If you need extra options, compute them in JavaScript before calling, not as extra arguments.
- Verify the date variable is actually bound in the script step's field list before the call.
Example fix
// before var nextDay = getNextWorkingDay(dateField, 'yyyy-MM-dd'); // after var nextDay = getNextWorkingDay(dateField);
Defensive patterns
Strategy: validation
Validate before calling
// JavaScript in the Kettle script step
if (arguments.length !== 1 || dateField === undefined || dateField === null) {
throw new Error('getNextWorkingDay requires exactly one date argument');
}
var nextDay = getNextWorkingDay(dateField); Type guard
function isDateArg(v) { return v instanceof Date || typeof v === 'number' || typeof v === 'string'; } Try / catch
try {
var nextDay = getNextWorkingDay(dateField);
} catch (e) {
if (String(e.message).indexOf('requires 1 argument') !== -1) {
// fix call site: pass exactly one date
} else { throw e; }
} Prevention
- Always call getNextWorkingDay with exactly one argument.
- Check argument count after editing/copy-pasting script code.
- Keep date transformations in dedicated test transformations before production use.
When it happens
Trigger: Calling getNextWorkingDay() with no arguments, or getNextWorkingDay(date, extra) with two or more arguments, from JavaScript code inside a Modified Java Script Value / Script step.
Common situations: Copy-pasted JavaScript snippets that pass a format string alongside the date; missing variable binding so the date argument evaluates to nothing; misunderstanding that the function takes only the source date and no options object.
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
- The function call date2str requires 1, 2, 3, or 4 arguments.
- The function call dateAdd requires 3 arguments.
- The function call escapeHtml requires 1 argument.
- The function call escapeSQL requires 1 argument.
- The function call escapeXml requires 1 argument.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/da4a477ecadfeaff.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:634
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return undefinedValue;
}
java.util.Date dIn = (java.util.Date) ArgList[0];
Calendar startDate = Calendar.getInstance();
startDate.setTime( dIn );
startDate.add( Calendar.DATE, 1 );
while ( startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SATURDAY
|| startDate.get( Calendar.DAY_OF_WEEK ) == Calendar.SUNDAY ) {
startDate.add( Calendar.DATE, 1 );
}
return startDate.getTime();
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call getNextWorkingDay requires 1 argument." );
}
}
public static Object dateAdd( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
if ( ArgList.length == 3 ) {
try {
if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
return undefinedValue;
}
java.util.Date dIn = (java.util.Date) ArgList[0];
String strType = ( (String) ArgList[1] ).toLowerCase();
int iValue = (Integer) ArgList[2];
Calendar cal = Calendar.getInstance();
cal.setTime( dIn );
if ( strType.equals( "y" ) ) {View on GitHub (pinned to f3058517a1)