pentaho/pentaho-kettle · error

The function call rtrim requires 1 argument.

Error message

The function call rtrim requires 1 argument.

What it means

Argument-count guard in ScriptValuesAddedFunctions.rtrim, which strips trailing whitespace from a string. It fires when a JavaScript script calls rtrim with an argument count other than exactly 1; the guard raises a Rhino runtime error. Fix by calling rtrim with exactly one string argument.

Solutions

  1. Call with a single string argument: rtrim(myString)
  2. For custom trailing characters, use myString.replace(/[chars]+$/, '') directly
  3. Confirm the upstream field contains a single string value

Example fix

// before
var s = rtrim(value, '\t');
// after
var s = rtrim(value);
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof s !== 'string') s = String(s == null ? '' : s);
var t = rtrim(s);

Type guard

function isStr(v) { return typeof v === 'string'; }

Try / catch

try { var t = rtrim(s); } catch (e) { if (String(e).indexOf('requires 1 argument') >= 0) { /* fix arity */ } else { throw e; } }

Prevention

When it happens

Trigger: Calling rtrim() with no arguments, or rtrim(str, chars) with a SQL-style character-set second argument the implementation does not support.

Common situations: Porting Oracle/SQL Server RTRIM(expr, chars) calls; accidentally splitting arguments; piping a two-element array where one string was expected.

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


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/01ffe8a02ee1a13f. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:800

      }
    } catch ( Exception e ) {
      throw Context.reportRuntimeError( "The function call ltrim is not valid : " + e.getMessage() );
    }
  }

  public static String rtrim( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    try {
      if ( ArgList.length == 1 ) {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return (String) Context.getUndefinedValue();
        }
        String strValueToTrim = Context.toString( ArgList[0] );
        return strValueToTrim.replaceAll( "\\s+$", "" );
      } else {
        throw Context.reportRuntimeError( "The function call rtrim requires 1 argument." );
      }
    } catch ( Exception e ) {
      throw Context.reportRuntimeError( "The function call rtrim is not valid : " + e.getMessage() );
    }
  }

  public static String lpad( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function 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) Context.getUndefinedValue();
        }
        String valueToPad = Context.toString( ArgList[0] );

View on GitHub (pinned to f3058517a1)