pentaho/pentaho-kettle · error · RhinoRuntimeError
The function call substr requires 2 or 3 arguments.
Error message
The function call substr requires 2 or 3 arguments.
What it means
Argument-count guard in ScriptValuesAddedFunctions.substr, which extracts a substring JavaScript-style (start index, optional length; negative lengths clamped to 0 and out-of-range ends clamped to string length). It fires when the script calls substr with fewer than 2 or more than 3 arguments; Rhino raises a runtime error. Fix by calling substr with a string plus a start index, optionally a length, e.g. substr(s, 0, 5).
Solutions
- Call substr(string, start) or substr(string, start, length)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1703 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/31639206a82914d4.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1703
if ( from < 0 ) {
throw Context.reportRuntimeError( "start smaller than 0" );
}
if ( len < 0 ) {
len = 0; // Make it compatible with Javascript substr
}
to = from + len;
strLen = sRC.length();
if ( to > strLen ) {
to = strLen;
}
sRC = sRC.substring( from, to );
} catch ( Exception e ) {
throw Context.reportRuntimeError( "The function call substr is not valid : " + e.getMessage() );
}
} else {
throw Context.reportRuntimeError( "The function call substr requires 2 or 3 arguments." );
}
return sRC;
}
// Resolve an IP address
public static String resolveIP( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
String sRC;
if ( ArgList.length == 2 ) {
try {
InetAddress address = InetAddress.getByName( Context.toString( ArgList[0] ) );
if ( Context.toString( ArgList[1] ).equals( "IP" ) ) {
sRC = address.getHostName();
} else {
sRC = address.getHostAddress();
}
if ( sRC.equals( Context.toString( ArgList[0] ) ) ) {
sRC = "-";View on GitHub (pinned to f3058517a1)