pentaho/pentaho-kettle · error · RhinoRuntimeError
start smaller than 0
Error message
start smaller than 0
What it means
Domain guard in substr's 3-argument branch: the start position computed from ArgList[1] is negative, which String.substring rejects. The check fires before length clamping (negative lengths are silently treated as 0 for JS compatibility, but negative starts are not).
Solutions
- Use a zero-based non-negative start index
- Clamp the start in script: Math.max(0, start)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1687 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/aca667e7b1107399.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1687
} catch ( Exception e ) {
throw Context.reportRuntimeError( "The function call substr is not valid : " + e.getMessage() );
}
} else if ( ArgList.length == 3 ) {
try {
int to;
int strLen;
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) Context.getUndefinedValue();
}
sRC = Context.toString( ArgList[0] );
int from = (int) Math.round( Context.toNumber( ArgList[1] ) );
int len = (int) Math.round( Context.toNumber( ArgList[2] ) );
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;View on GitHub (pinned to f3058517a1)