pentaho/pentaho-kettle · error · Rhino runtime error

The function call escapeSQL requires 1 argument.

Error message

The function call escapeSQL requires 1 argument.

What it means

escapeSQL sanitizes a string for safe SQL embedding via Const.escapeSQL in the Modified Java Script Value step. The library throws this Rhino runtime error when the function is called with an argument count other than 1 — only a single input string is accepted.

Solutions

  1. Call escapeSQL with exactly one string argument: escapeSQL(sqlFragment)
  2. Prefer parameterized queries over string escaping for actual SQL safety
  3. Verify the argument is not null/empty before calling

Example fix

// before
var safe = escapeSQL(value, connection);
// after
var safe = escapeSQL(value);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof sqlFragment === 'string' && sqlFragment.length > 0) { var safe = escapeSQL(sqlFragment); }

Type guard

function isNonEmptyString(v){ return typeof v === 'string' && v.length > 0; }

Try / catch

try { var safe = escapeSQL(sqlFragment); } catch (e) { throw new Error('escapeSQL requires exactly 1 argument: ' + e.message); }

Prevention

When it happens

Trigger: escapeSQL() with no arguments, or escapeSQL(s, extra) with additional arguments; the length==1 guard fails and Context.reportRuntimeError fires.

Common situations: Users passing a connection or dialect as a second argument; accidentally deleting the argument variable so the array is empty.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

    }
  }

  public static String unEscapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.unEscapeXml( Context.toString( ArgList[0] ) );
    } else {
      throw Context.reportRuntimeError( "The function call unEscapeXml requires 1 argument." );

    }
  }

  public static String escapeSQL( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.escapeSQL( Context.toString( ArgList[0] ) );
    } else {
      throw Context.reportRuntimeError( "The function call escapeSQL requires 1 argument." );

    }
  }

  public static String protectXMLCDATA( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.protectXMLCDATA( Context.toString( ArgList[0] ) );
    } else {
      throw Context.reportRuntimeError( "The function call protectXMLCDATA requires 1 argument." );

    }
  }

  public static String removeDigits( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.removeDigits( Context.toString( ArgList[0] ) );

View on GitHub (pinned to f3058517a1)