pentaho/pentaho-kettle · error · RuntimeException
The function call dateAdd requires 3 arguments.
Error message
The function call dateAdd requires 3 arguments.
What it means
dateAdd requires exactly three arguments: the date, the integer amount to add, and the unit string. When ArgList.length != 3 the function short-circuits and throws this RuntimeException before doing any work. It is an argument-count guard, thrown from the else branch of the argument check.
Solutions
- Call with exactly three positional arguments: dateAdd(date, amount, unit).
- Add the missing amount or unit argument.
- Split extra data into separate script variables instead of additional arguments.
Example fix
// before var newDate = dateAdd(orderDate, 'dd'); // after var newDate = dateAdd(orderDate, 7, 'dd');
Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length !== 3) {
throw new Error('dateAdd requires exactly 3 arguments: (date, amount, unit)');
}
var newDate = dateAdd(dateField, amount, unit); Type guard
function hasThreeArgs() { return arguments.length === 3; } Try / catch
try {
var newDate = dateAdd(dateField, amount, unit);
} catch (e) {
if (String(e.message).indexOf('requires 3 arguments') !== -1) {
throw new Error('Call dateAdd as dateAdd(date, amount, unit)');
} else { throw e; }
} Prevention
- Remember the signature: dateAdd(date, amount, unit) — three positional arguments.
- Do not pass options objects or extra parameters.
- Centralize date arithmetic in one reviewed script function per transformation.
When it happens
Trigger: Calling dateAdd() with fewer than three arguments or more than three, e.g. dateAdd(date, 'dd') (missing amount) or dateAdd(date, 1, 'dd', extra).
Common situations: Confusing this API with java.util-style APIs that take (unit, amount, date); forgetting the unit argument; passing an options object instead of positional 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
- The function call date2str requires 1, 2, 3, or 4 arguments.
- The function call escapeHtml requires 1 argument.
- The function call escapeSQL requires 1 argument.
- The function call escapeXml requires 1 argument.
- The function call fillString requires 2 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/25d4c68418e6aabb.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:681
int day = cal.get( Calendar.DAY_OF_WEEK );
cal.add( Calendar.DATE, 1 );
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 new RuntimeException( e.toString() );
}
} else {
throw new RuntimeException( "The function call dateAdd requires 3 arguments." );
}
}
public static String fillString( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object 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) undefinedValue;
}
String fillChar = (String) ArgList[0];
int count = (Integer) ArgList[1];
if ( fillChar.length() != 1 ) {
throw new RuntimeException( "Please provide a valid Char to the fillString" );
} else {
char[] chars = new char[count];View on GitHub (pinned to f3058517a1)