pentaho/pentaho-kettle · error · RuntimeException
The function call ltrim requires 1 argument.
Error message
The function call ltrim requires 1 argument.
What it means
ltrim strips leading whitespace from a string and requires exactly one argument. When ArgList.length != 1 it throws this RuntimeException. The check sits inside an outer try, but this specific throw happens before the per-argument processing.
Solutions
- Call with exactly one argument: ltrim(str).
- Remove any second character-set argument; if you need custom trimming, use str.replace(/^\s+/, '') or a char-class regex in JavaScript.
- Ensure the field value is passed explicitly, not assumed from context.
Example fix
// before var trimmed = ltrim(name, ' '); // after var trimmed = ltrim(name);
Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length !== 1 || typeof str !== 'string') {
throw new Error('ltrim requires exactly one string argument');
}
var trimmed = ltrim(str); Type guard
function isStringArg(v) { return typeof v === 'string' || v instanceof String; } Try / catch
try {
var trimmed = ltrim(str);
} catch (e) {
if (String(e.message).indexOf('requires 1 argument') !== -1) {
throw new Error('Call ltrim with exactly one argument');
} else { throw e; }
} Prevention
- Call ltrim with exactly one argument; it has no character-set parameter.
- Use str.replace(/^\s+/, '') directly for custom trimming needs.
- Pass the field value explicitly rather than relying on implicit bindings.
When it happens
Trigger: Calling ltrim() with no arguments, or ltrim(str, chars) with a second character-set argument (not supported by this API).
Common situations: Porting from ltrim implementations (e.g. Oracle/PHP) that accept a character list as the second argument; calling without arguments expecting it to operate on a bound field.
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 initCap requires 1 argument.
- The function call removeDigits requires 1 argument.
- The function call rtrim requires 1 argument.
- Please provide a valid Char to the fillString
- The function call date2str requires 1, 2, 3, or 4 arguments.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/8ecc4abcd3c7821c.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:751
} else {
throw new RuntimeException( "The function call isCodepage requires 2 arguments." );
}
return Boolean.valueOf( bRC );
}
public static String ltrim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) undefinedValue;
}
String strValueToTrim = (String) ArgList[0];
return strValueToTrim.replaceAll( "^\\s+", "" );
} else {
throw new RuntimeException( "The function call ltrim requires 1 argument." );
}
} catch ( Exception e ) {
throw new RuntimeException( "The function call ltrim is not valid : " + e.getMessage() );
}
}
public static String rtrim( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
try {
if ( ArgList.length == 1 ) {
if ( isNull( ArgList[0] ) ) {
return null;
} else if ( isUndefined( ArgList[0] ) ) {
return (String) undefinedValue;
}
String strValueToTrim = (String) ArgList[0];
return strValueToTrim.replaceAll( "\\s+$", "" );
} else {View on GitHub (pinned to f3058517a1)