pentaho/pentaho-kettle · error
The function call dateAdd requires 3 arguments.
Error message
The function call dateAdd requires 3 arguments.
What it means
dateAdd is a Kettle Rhino extension function that adds an amount of a given unit (y, M, d, h, m, s) to a date. It requires exactly 3 arguments: date, unit string, and integer amount. Any other argument count throws this RuntimeError.
Solutions
- Call with three arguments: dateAdd(myDate, 'd', 1)
- Make sure the amount is a number, not a string, to avoid the exception path inside the try block
- Check that all three values are defined before the call
Example fix
// before var later = dateAdd(now, 'd'); // after var later = dateAdd(now, 'd', 1);
Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length !== 3) throw new Error('dateAdd(date, unit, amount) requires 3 arguments');
if (typeof amount !== 'number') amount = parseInt(amount, 10); Try / catch
try { var nd = dateAdd(d, unit, n); } catch (e) { throw new Error('dateAdd misuse: ' + e.message); } Prevention
- Use the fixed order: date, unit string, numeric amount
- Coerce field-based amounts to numbers before calling
- Do not pass moment/date-fns style objects
When it happens
Trigger: Calling dateAdd with 2 arguments (missing the amount) or 4+ arguments; passing the unit and amount in the wrong order still passes the count check but the runtime error appears when the count differs.
Common situations: Scripts ported from other JS date libraries with different signatures (e.g. moment-style dateAdd(d, {days:1})); the increment value stored in a field that is null/undefined so the developer removed it.
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 dateDiff requires 3 arguments.
- The function call getNextWorkingDay requires 1 argument.
- The function call fillString requires 2 arguments.
- The function call fireToDB requires 2 arguments.
- The function call getDayNumber requires 2 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/cca0518d1a829124.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:711
cal.add( Calendar.DATE, 1 );
int day = cal.get( Calendar.DAY_OF_WEEK );
if ( ( day != Calendar.SATURDAY ) && ( day != Calendar.SUNDAY ) ) {
iOffset++;
}
}
} else if ( strType.equals( "hh" ) ) {
cal.add( Calendar.HOUR, iValue );
} else if ( strType.equals( "mi" ) ) {
cal.add( Calendar.MINUTE, iValue );
} else if ( strType.equals( "ss" ) ) {
cal.add( Calendar.SECOND, iValue );
}
return cal.getTime();
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
} else {
throw Context.reportRuntimeError( "The function call dateAdd requires 3 arguments." );
}
}
public static String fillString( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 2 ) {
try {
if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
return (String) Context.getUndefinedValue();
}
String fillChar = Context.toString( ArgList[0] );
int count = (int) Context.toNumber( ArgList[1] );
if ( fillChar.length() != 1 ) {
throw Context.reportRuntimeError( "Please provide a valid Char to the fillString" );
} else {
char[] chars = new char[count];View on GitHub (pinned to f3058517a1)