pentaho/pentaho-kettle · error · RuntimeException
The function call month requires 1 argument.
Error message
The function call month requires 1 argument.
What it means
Arity guard in ScriptAddedFunctions.month: the script call's ArgList length is not 1. The single expected argument is a java.util.Date; with correct arity the function returns the Calendar month as a Double, otherwise this RuntimeException is thrown to the script engine.
Solutions
- Call month() with exactly one Date argument.
- Remember the result is 0-based; add 1 for human-readable months.
- Convert strings with str2date() first.
- Null-check the date before the call.
Example fix
// before var m = month(); // after var m = month(dateField) + 1; // Calendar.MONTH is 0-based
Defensive patterns
Strategy: validation
Validate before calling
var m = (d != null) ? month(d) + 1 : null; // Calendar.MONTH is 0-based
Type guard
function isKettleDate(v) { return v != null && v instanceof java.util.Date; } Try / catch
try {
var m = month(d);
} catch (e) {
Logger.LogBasic("month failed: " + e.message);
m = null;
} Prevention
- Pass exactly one Date argument.
- Remember the 0-based result; add 1 for display.
- Convert strings via str2date().
- Null-check before calling.
When it happens
Trigger: Calling month() with zero or multiple arguments in a Script step, or an argument flow that fails the ArgList.length == 1 check.
Common situations: Expecting 1-based months (Calendar.MONTH is 0-based, January = 0); passing string dates; chaining calls with wrong arity.
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 quarter requires 1 argument.
- The function call week requires 1 argument.
- The function call year requires 1 argument.
- The function call lpad requires 3 arguments.
- The function call rpad requires 3 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/6643d9125dde2cd7.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:862
throw new RuntimeException( e.toString() );
}
}
public static Object month( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return new Double( Double.NaN );
} else if ( isUndefined( ArgList[0] ) ) {
return undefinedValue;
}
java.util.Date dArg1 = (java.util.Date) ArgList[0];
Calendar cal = Calendar.getInstance();
cal.setTime( dArg1 );
return new Double( cal.get( Calendar.MONTH ) );
} else {
throw new RuntimeException( "The function call month requires 1 argument." );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
}
public static Object quarter( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return new Double( Double.NaN );
} else if ( isUndefined( ArgList[0] ) ) {
return undefinedValue;
}
java.util.Date dArg1 = (java.util.Date) ArgList[0];
Calendar cal = Calendar.getInstance();View on GitHub (pinned to f3058517a1)