pentaho/pentaho-kettle · error · JavaScriptException
The function call month requires 1 argument.
Error message
The function call month requires 1 argument.
What it means
The month() JavaScript function returns the calendar month of a Date argument as a number (0-based, per java.util.Calendar.MONTH). It throws this runtime error when not called with exactly one argument.
Solutions
- Call month() with exactly one Date argument.
- Convert string dates with str2Date() before calling month().
- Null-check the field; note the result is 0-based (add 1 for human-readable month).
- Verify the field type is Date in the step's field definitions.
Example fix
// before var m = month(); // after var m = month(myDateField) + 1; // Calendar.MONTH is 0-based
Defensive patterns
Strategy: validation
Validate before calling
if (myDateField == null) throw 'month: date is null'; var m = month(myDateField) + 1; // 0-based
Type guard
function isDate(v) { return v != null && v.getClass && String(v.getClass()) === 'class java.util.Date'; } Try / catch
try { var m = month(myDateField) + 1; } catch (e) { var m = null; } Prevention
- Pass exactly one Date argument
- Remember Calendar.MONTH is 0-based (Jan=0)
- Use str2Date() for string inputs
- Validate the field type before date functions
When it happens
Trigger: Calling month() with zero or multiple arguments in a modified JavaScript step; or with an argument that fails the Date conversion, which is then re-thrown as e.toString().
Common situations: Forgetting the date field argument, passing a date string without str2Date(), or expecting 1-based month semantics and misreading the result afterwards.
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.
- Error in isEmpty function:
- Script.Log.CouldNotAddDefaultConstants
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/f47ed028948cffb7.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:892
throw Context.reportRuntimeError( e.toString() );
}
}
public static Object month( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return new Double( Double.NaN );
} else if ( isUndefined( ArgList[0] ) ) {
return Context.getUndefinedValue();
}
java.util.Date dArg1 = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
Calendar cal = Calendar.getInstance();
cal.setTime( dArg1 );
return new Double( cal.get( Calendar.MONTH ) );
} else {
throw Context.reportRuntimeError( "The function call month requires 1 argument." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
public static Object quarter( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return new Double( Double.NaN );
} else if ( isUndefined( ArgList[0] ) ) {
return Context.getUndefinedValue();
}
java.util.Date dArg1 = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );
Calendar cal = Calendar.getInstance();View on GitHub (pinned to f3058517a1)