pentaho/pentaho-kettle · error · Rhino runtime error

The function call protectXMLCDATA requires 1 argument.

Error message

The function call protectXMLCDATA requires 1 argument.

What it means

protectXMLCDATA wraps a string safely in CDATA using Const.protectXMLCDATA in the Modified Java Script Value step. This error is thrown when the function is invoked with an argument count other than exactly 1, as the wrapper handles a single string only.

Solutions

  1. Call protectXMLCDATA with exactly one argument: protectXMLCDATA(text)
  2. Remove extra options arguments; behavior is fixed by Const.protectXMLCDATA
  3. Inspect the function help in the step's JS function tree

Example fix

// before
var cdata = protectXMLCDATA(text, true);
// after
var cdata = protectXMLCDATA(text);
Defensive patterns

Strategy: validation

Validate before calling

if (typeof text === 'string') { var cdata = protectXMLCDATA(text); }

Type guard

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

Try / catch

try { var cdata = protectXMLCDATA(text); } catch (e) { throw new Error('protectXMLCDATA requires exactly 1 argument: ' + e.message); }

Prevention

When it happens

Trigger: protectXMLCDATA() with zero arguments or protectXMLCDATA(s, x) with extra arguments; ArgList.length != 1 hits the else and throws.

Common situations: Users trying to pass a second option like 'alreadyWrapped'; scripts copied from other XML libraries with richer signatures.

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/1ae4be8c64155d03. Report an issue: GitHub.

Appendix: source

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

    }
  }

  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] ) );
    } else {
      throw Context.reportRuntimeError( "The function call removeDigits requires 1 argument." );

    }
  }

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

View on GitHub (pinned to f3058517a1)