pentaho/pentaho-kettle · error · RuntimeException
The function call rtrim requires 1 argument.
Error message
The function call rtrim requires 1 argument.
What it means
rtrim strips trailing whitespace from a string and requires exactly one argument. When ArgList.length != 1 it throws this RuntimeException. Symmetric to ltrim's guard, this check runs before any trimming work.
Solutions
- Call with exactly one argument: rtrim(str).
- Remove extra arguments; for custom trailing characters use str.replace(/\s+$/, '') or a targeted regex in JavaScript.
- Convert non-string values with String(value) before calling to also avoid the related 'not valid' wrapper error.
Example fix
// before var trimmed = rtrim(name, '\t'); // after var trimmed = rtrim(name);
Defensive patterns
Strategy: validation
Validate before calling
if (arguments.length !== 1 || typeof str !== 'string') {
throw new Error('rtrim requires exactly one string argument');
}
var trimmed = rtrim(str); Type guard
function isStringArg(v) { return typeof v === 'string' || v instanceof String; } Try / catch
try {
var trimmed = rtrim(str);
} catch (e) {
if (String(e.message).indexOf('requires 1 argument') !== -1) {
throw new Error('Call rtrim with exactly one argument');
} else { throw e; }
} Prevention
- Call rtrim with exactly one argument; no character-set parameter is supported.
- Use str.replace(/\s+$/, '') for trimming custom trailing characters.
- Coerce non-string values with String(value) before calling.
When it happens
Trigger: Calling rtrim() with no arguments, or rtrim(str, chars) passing a character-set second argument that this API does not accept.
Common situations: Porting code from rtrim variants that take a character list; forgetting to pass the field because another function bound it implicitly.
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 ltrim requires 1 argument.
- The function call removeDigits 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/beeab079314928bb.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:770
}
} 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 {
throw new RuntimeException( "The function call rtrim requires 1 argument." );
}
} catch ( Exception e ) {
throw new RuntimeException( "The function call rtrim is not valid : " + e.getMessage() );
}
}
public static String lpad( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
Object FunctionContext ) {
// (String valueToPad, String filler, int size) {
try {
if ( ArgList.length == 3 ) {
if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
return (String) undefinedValue;
}
String valueToPad = (String) ArgList[0];View on GitHub (pinned to f3058517a1)