pentaho/pentaho-kettle · error · JavaScriptException

The function call lower is not valid

Error message

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

What it means

The lower() counterpart of error 2016: thrown when lower(x) fails while converting its argument to a string and lowercasing it. Exceptions from Context.toString(ArgList[0]) or toLowerCase() are caught and re-thrown as 'The function call lower is not valid : ' + e.getMessage(), masking the original cause.

Solutions

  1. Coerce explicitly first: lower(String(value)).
  2. Inspect the e.getMessage() suffix for the real conversion error.
  3. Null-check before calling: value == null ? null : lower(value).
  4. Convert Java objects to strings in the previous step rather than inside the script.

Example fix

// before
var l = lower(emailObj)
// after
var l = (emailObj == null) ? null : lower(String(emailObj))
Defensive patterns

Strategy: type-guard

Validate before calling

// JS
function safeLower(v) { return (v == null) ? null : lower(String(v)); }

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling lower(x) where x is a complex/Java-wrapped object that cannot be stringified, a value whose conversion throws in the Rhino context, or an internal failure during toLowerCase on unusual input.

Common situations: Applying lower() to binary or Blob fields; passing NativeJavaObject values from earlier Java-class steps; scripts using undefined row variables that resolve to odd Java objects.

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

Appendix: source

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

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

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

View on GitHub (pinned to f3058517a1)