pentaho/pentaho-kettle · error · RuntimeException

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

Error message

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

What it means

Thrown by the upper() helper of the PDI Script step when toUpperCase() fails on the supplied argument — typically because the argument is not a String (cast to String fails) or another exception occurs during conversion.

Solutions

  1. Convert the value to a string first: upper('' + myField) or upper(num2str(myField)).
  2. Check the input field type in the transform preceding the Script step and add a 'Select values' step to type it as String.
  3. Inspect e.getMessage() in the message to identify the concrete cause.

Example fix

// before
upper(orderDate)
// after
upper('' + orderDate)
Defensive patterns

Strategy: type-guard

Validate before calling

function safeUpper(v) { return (v === null || v === undefined) ? null : upper(String(v)); }

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling upper(x) with 1 argument where x is a non-string object that cannot be cast to java.lang.String (e.g. a Date or number object in certain engines) — the ClassCastException inside the try is wrapped with this message.

Common situations: Passing a numeric or Date field directly instead of converting to string first; passing null-ish script values in engines where the isNull/isUndefined checks did not cover the value.

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/ce4f2b86f30d2482. Report an issue: GitHub.

Appendix: source

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

    } else {
      throw new RuntimeException( "The function call sendMail requires 5 arguments." );
    }
  }

  public static String upper( 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.toUpperCase();
      } catch ( Exception e ) {
        throw new RuntimeException( "The function call upper is not valid : " + e.getMessage() );
      }
    } else {
      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];

View on GitHub (pinned to f3058517a1)