pentaho/pentaho-kettle · error · RuntimeException

The function call lower is not valid : " + e.getMessage()

Error message

The function call lower is not valid : " + e.getMessage()

What it means

Failure path in ScriptAddedFunctions.lower: an exception was caught while lower-casing ArgList[0] — most commonly a ClassCastException because the argument is not a String — and it is rethrown as a RuntimeException with the caught message appended. (The recorded message string itself contains a literal concatenation typo from the source.)

Solutions

  1. Coerce to string first: lower('' + myField) or use str/num2str conversion.
  2. Ensure the incoming field is typed as String (use a 'Select values' step before the Script).
  3. Read the wrapped e.getMessage() for the concrete cause.

Example fix

// before
lower(accountId)
// after
lower('' + accountId)
Defensive patterns

Strategy: type-guard

Validate before calling

function safeLower(v) { return (v === null || v === undefined) ? null : lower(String(v)); }

Type guard

function isString(v) { return typeof v === 'string' || v instanceof java.lang.String; }

Try / catch

try { return lower(v); }
catch (e) { if (/lower is not valid/.test(e.message)) return String(v).toLowerCase(); throw e; }

Prevention

When it happens

Trigger: Calling lower(x) where x is not a String (e.g. a number, Date, or Java object), causing the cast/conversion inside the try block to throw, wrapped with this message.

Common situations: Passing a numeric key or date field directly; locale-sensitive value objects from earlier Java steps leaking into the script.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:1286

      throw new RuntimeException( "The function call upper requires 1 argument." );
    }
    return sRC;
  }

  public static String lower( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    String sRC = "";
    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return (String) undefinedValue;
        }
        sRC = (String) ArgList[0];
        sRC = sRC.toLowerCase();
      } catch ( Exception e ) {
        throw new RuntimeException( "The function call lower is not valid : " + e.getMessage() );
      }
    } else {
      throw new RuntimeException( "The function call lower requires 1 argument." );
    }
    return sRC;
  }

  // Converts the given Numeric to a JScript String
  public static String num2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    String sRC = "";
    switch ( ArgList.length ) {
      case 0:
        throw new RuntimeException( "The function call num2str requires at least 1 argument." );
      case 1:
        try {
          if ( isNull( ArgList[0] ) ) {
            return null;

View on GitHub (pinned to f3058517a1)