pentaho/pentaho-kettle · error · Rhino runtime error

The function call removeCRLF is not valid

Error message

The function call removeCRLF is not valid

What it means

removeCRLF() wraps its logic in a try/catch; if Const.removeCRLF or argument conversion throws, a generic 'The function call removeCRLF is not valid' Rhino runtime error is reported. This is the exception branch of the function.

Solutions

  1. Coerce the argument to a JS string first: removeCRLF(String(value)).
  2. Inspect the row field type feeding the script.
  3. Use a Select values step to convert the field to String before the Script step.

Example fix

// before
var clean = removeCRLF(someJavaObject);
// after
var clean = removeCRLF(String(someJavaObject));
Defensive patterns

Strategy: type-guard

Validate before calling

// JS
if (value == null) value = '';

Type guard

function isStr(v){ return typeof v === 'string'; }

Try / catch

try { var clean = removeCRLF(String(value)); } catch (e) { /* fallback */ }

Prevention

When it happens

Trigger: removeCRLF(value) is called with an argument present but whose conversion to a Java String throws (unusual Rhino wrapper objects, NativeJavaObject issues).

Common situations: Passing a Java object from a previous step rather than a string, or corrupted row values.

Understand the failure class

Background: "must be a positive integer", "cannot be empty", "invalid argument": how invalid-argument errors work across open-source libraries — this error's family across 33 libraries.

Related errors


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

Appendix: source

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

    } else {
      throw Context.reportRuntimeError( "The function call getOcuranceString is not valid" );
    }
    return nr;
  }

  public static String removeCRLF( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      try {
        if ( isNull( ArgList[0] ) ) {
          return null;
        } else if ( isUndefined( ArgList[0] ) ) {
          return (String) Context.getUndefinedValue();
        }

        return Const.removeCRLF( Context.toString( ArgList[0] ) );
      } catch ( Exception e ) {
        throw Context.reportRuntimeError( "The function call removeCRLF is not valid" );
      }
    } else {
      throw Context.reportRuntimeError( "The function call removeCRLF is not valid" );
    }
  }
}

View on GitHub (pinned to f3058517a1)