pentaho/pentaho-kettle · error · JavaScriptException

The function call upper is not valid

Error message

The function call upper is not valid : {e.getMessage()}

What it means

Thrown by the upper() JavaScript function when converting its single argument to a string and uppercasing it fails. Any exception in that block is caught and re-thrown as 'The function call upper is not valid : ' + e.getMessage(). This is typically caused by an argument that Context.toString() cannot handle or an unexpected runtime condition inside the Rhino context.

Solutions

  1. Pass a plain string or scalar: upper(String(fieldName)).
  2. Check the e.getMessage() suffix — it identifies the exact conversion failure.
  3. Handle nulls before the call: if (field == null) result = null; else result = upper(field).
  4. Unwrap Java objects with Context.toString or String() before applying upper.

Example fix

// before
var u = upper(rowObject)
// after
var u = (rowObject == null) ? null : upper(String(rowObject.someField))
Defensive patterns

Strategy: type-guard

Validate before calling

// JS
function safeUpper(v) { return (v == null) ? null : upper(String(v)); }

Type guard

function isStringLike(v) { return typeof v === 'string' || typeof v === 'number'; }

Try / catch

try { u = upper(v); } catch (e) { u = null; logError("upper failed: " + e.message); }

Prevention

When it happens

Trigger: Calling upper(x) where x is an object with no meaningful string coercion that throws, or internal conversion failures during Context.toString(ArgList[0]) — essentially any exception thrown inside the try block for a single-argument call.

Common situations: Passing null-filled row fields whose JavaScript representation trips conversion; passing complex objects (arrays of rows, NativeJavaObject wrappers) instead of scalars; Rhino context differences across Kettle versions.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

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

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

  public static String upper( 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 = sRC.toUpperCase();
      } catch ( Exception e ) {
        throw Context.reportRuntimeError( "The function call upper is not valid : " + e.getMessage() );
      }
    } else {
      throw Context.reportRuntimeError( "The function call upper requires 1 argument." );
    }
    return sRC;
  }

  public static String lower( 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] );

View on GitHub (pinned to f3058517a1)