pentaho/pentaho-kettle · error · RuntimeException
Please provide a valid string to the function call str2date.
Error message
Please provide a valid string to the function call str2date.
What it means
str2date() converts a string to a Date using an optional format. The switch on ArgList.length throws this RuntimeException in the case 0 branch — the function refuses to run with no arguments. At minimum the date string must be supplied.
Solutions
- Pass at least one argument: str2date('2026-09-13') or str2date(dateStringField).
- If the field may be empty, return null early in script instead of calling str2date.
- Check the script step's field mappings after transformation changes.
Example fix
// before var d = str2date(); // after var d = str2date(dateString, 'yyyy-MM-dd');
Defensive patterns
Strategy: validation
Validate before calling
if (dateString == null || dateString.length === 0) { var d = null; } else { var d = str2date(dateString, 'yyyy-MM-dd'); } Try / catch
try { var d = str2date(s, fmt); } catch (e) { logError('str2date failed: ' + e.message); d = null; } Prevention
- Always supply at least the date string argument
- Update script steps when renaming transformation fields
- Return null for empty inputs instead of calling str2date
When it happens
Trigger: Calling str2date() with zero arguments in a Modified Java Script Value step, usually because the source field was deleted or renamed.
Common situations: Renaming a transformation field without updating the script; copy-pasting a script where the argument was lost; building the argument dynamically and producing undefined.
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 truncDate requires 2 arguments: a date…
- The function call truncDate requires 2 arguments: a date…
- Argument of TRUNC of date has to be between 0 and 5
- Argument of TRUNC of date has to be between 0 and 5
- Could not apply local format for
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/81710027efc9f1a3.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:994
return Boolean.valueOf( file.isFile() );
} else {
throw new RuntimeException( "The function call fileExists requires 1 valid argument." );
}
} catch ( Exception e ) {
throw new RuntimeException( e.toString() );
}
}
public static Object str2date( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
Object oRC = new Object();
String sArg1 = "";
String sArg2 = "";
String sArg3 = "";
String sArg4 = "";
switch ( ArgList.length ) {
case 0:
throw new RuntimeException( "Please provide a valid string to the function call str2date." );
case 1:
try {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return undefinedValue;
}
sArg1 = (String) ArgList[0];
Format dfFormatter = new SimpleDateFormat();
oRC = dfFormatter.parseObject( sArg1 );
// if(Double.isNaN(sArg1)) throw new RuntimeException("The first Argument must be a Number.");
// DecimalFormat formatter = new DecimalFormat();
// sRC= formatter.format(sArg1);
} catch ( Exception e ) {
throw new RuntimeException( "Could not apply local format for " + sArg1 + " : " + e.getMessage() );
}
break;
case 2:View on GitHub (pinned to f3058517a1)