pentaho/pentaho-kettle · error

The function call escapeXml requires 1 argument.

Error message

The function call escapeXml requires 1 argument.

What it means

escapeXml is a built-in JS function in the Modified Java Script Value step that XML-escapes a string via Const.escapeXML. The library throws this Rhino runtime error when the function is called with an argument count other than exactly 1, since escaping requires a single input string.

Solutions

  1. Call escapeXml with exactly one string argument: escapeXml(myString)
  2. Remove any extra options/flags arguments and use Const escaping defaults
  3. Verify the script in the Modified Java Script Value dialog and test with a sample row

Example fix

// before
var safe = escapeXml(value, true);
// after
var safe = escapeXml(value);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof value === 'string') { var safe = escapeXml(value); }

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling escapeXml() with no arguments, or escapeXml(a, b) with multiple arguments; ArgList.length != 1 hits the else branch and throws.

Common situations: Copy-pasted scripts where a second argument was added for flags; calling the function on a variable that was accidentally deleted leaving no argument; mixing with a different library's escapeXml that accepts options.

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

Appendix: source

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

        }

        isValid = Boolean.TRUE;

      } catch ( Exception e ) {
        throw Context.reportRuntimeError( "Error in isMailValid function: " + e.getMessage() );
      }
      return isValid;
    } else {
      throw Context.reportRuntimeError( "The function call isMailValid is not valid" );
    }
  }

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

    }
  }

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

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

View on GitHub (pinned to f3058517a1)