pentaho/pentaho-kettle · error · RuntimeException
The function call str2date requires 1, 2, 3, or 4 arguments.
Error message
The function call str2date requires 1, 2, 3, or 4 arguments.
What it means
str2date only supports 1, 2, 3, or 4 arguments (date string, optional format, optional locale, optional timezone). Calling it with 0 or 5+ arguments falls into the switch default and throws this RuntimeException.
Solutions
- Call str2date with 1-4 arguments: the date string at minimum.
- Remove extra arguments; format/locale/timezone are positional.
- If you need more options, pre-process the string in script instead of adding arguments.
- Check the script step's generated code (e.g. compatibility flags) that may alter argument lists.
Example fix
// before var d = str2date(s, 'yyyy-MM-dd', 'en', 'UTC', 'extra'); // after var d = str2date(s, 'yyyy-MM-dd', 'en', 'UTC');
Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length < 1 || arguments.length > 4) throw new Error('str2date requires 1-4 arguments, got ' + arguments.length); Try / catch
try { var d = str2date.apply(null, args.slice(0, 4)); } catch (e) { if (String(e.message).indexOf('requires 1, 2, 3, or 4 arguments') >= 0) { throw new Error('bad str2date call, args=' + args.length); } throw e; } Prevention
- Call str2date with at most 4 positional arguments (string, format, locale, timezone)
- Never pass extra/optional config objects as additional arguments
- Review generated script code for duplicated arguments
- Always supply at least the date string
When it happens
Trigger: Invoking str2date() with no arguments, or with 5+ arguments (e.g. accidentally passing extra parameters), from a JavaScript script step.
Common situations: Typos or refactored scripts leaving stray arguments; misunderstanding the signature and passing extra options; generated/templated script code emitting wrong argument counts.
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
- Please provide a valid date to the function call date2str.
- Row.EndOfFileReached
- Row.EndOfFileReadingRow
- Row.ErrorWritingRow
- Row.RowError
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/0bd15a1caf048363.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1082
// If the timezone is not recognized, java will automatically
// take GMT.
TimeZone tz = TimeZone.getTimeZone( sArg4 );
if ( sArg3.length() == 2 ) {
Locale dfLocale = EnvUtil.createLocale( sArg3 );
dfFormatter = new SimpleDateFormat( sArg2, dfLocale );
dfFormatter.setTimeZone( tz );
oRC = dfFormatter.parseObject( sArg1 );
} else {
throw new RuntimeException( "Locale " + sArg3 + " is not 2 characters long." );
}
} catch ( Exception e ) {
throw new RuntimeException( "Could not apply the local format for locale "
+ sArg3 + " with the given format " + sArg2 + " on the string for " + sArg1 + " : " + e.getMessage() );
}
break;
default:
throw new RuntimeException( "The function call str2date requires 1, 2, 3, or 4 arguments." );
}
return oRC;
}
public static Object date2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
Object oRC = new Object();
switch ( ArgList.length ) {
case 0:
throw new RuntimeException( "Please provide a valid date to the function call date2str." );
case 1:
try {
if ( isNull( ArgList ) ) {
return null;
} else if ( isUndefined( ArgList ) ) {
return undefinedValue;
}
java.util.Date dArg1 = (java.util.Date) ArgList[0];View on GitHub (pinned to f3058517a1)