pentaho/pentaho-kettle · error · JavaScriptException
The function call quarter requires 1 argument.
Error message
The function call quarter requires 1 argument.
What it means
Argument-count guard in ScriptValuesAddedFunctions.quarter, which maps a Date's month to its calendar quarter (1-4). It fires when the script calls quarter with an argument count other than exactly 1; Rhino raises a runtime error before any date computation. Fix by passing exactly one Date argument, e.g. quarter(orderDate).
Solutions
- Call quarter() with exactly one Date argument.
- Use str2Date() to convert string dates first.
- Null-check the date field before the call.
- Verify the incoming field is a Date type, not a string.
Example fix
// before
var q = quarter('2024-05-01');
// after
var q = quarter(str2Date('2024-05-01', 'yyyy-MM-dd')); Defensive patterns
Strategy: validation
Validate before calling
if (myDateField == null) throw 'quarter: date is null'; var q = quarter(myDateField);
Type guard
function isDate(v) { return v != null && v.getClass && String(v.getClass()) === 'class java.util.Date'; } Try / catch
try { var q = quarter(myDateField); } catch (e) { var q = null; } Prevention
- Pass exactly one Date argument
- Convert strings with str2Date() first
- Null-check fields before the call
- Verify quarter expectations (1-4) when consuming the result
When it happens
Trigger: Calling quarter() with zero or multiple arguments in a modified JavaScript step, or passing a non-Date value that fails the internal month extraction.
Common situations: Omitting the date argument when adapting SQL-style scripts, passing a string date, or null fields arriving from upstream steps.
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 month 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/6fbcf42432ff3b2a.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:925
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 );
// Patch by Ingo Klose: calendar months start at 0 in java.
int iMonth = cal.get( Calendar.MONTH );
if ( iMonth <= 2 ) {
return new Double( 1 );
} else if ( iMonth <= 5 ) {
return new Double( 2 );
} else if ( iMonth <= 8 ) {
return new Double( 3 );
} else {
return new Double( 4 );
}
} else {
throw Context.reportRuntimeError( "The function call quarter requires 1 argument." );
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( e.toString() );
}
}
public static Object week( 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 );View on GitHub (pinned to f3058517a1)