pentaho/pentaho-kettle · error · RhinoRuntimeError

The function call trim requires 1 argument.

Error message

The function call trim requires 1 argument.

What it means

Argument-count guard in ScriptValuesAddedFunctions.trim, which removes leading and trailing whitespace via Const.trim. It fires when the script calls trim with an argument count other than exactly 1; Rhino raises a runtime error before trimming. Fix by passing exactly one string argument, e.g. trim(name).

Solutions

  1. Call trim(value) with exactly one argument
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1650 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/24147a2817f297b1. Report an issue: GitHub.

Appendix: source

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

  }

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

  public static String substr( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    String sRC = "";

    if ( ArgList.length == 2 ) {
      try {
        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] ) );
        sRC = sRC.substring( from );

View on GitHub (pinned to f3058517a1)