{"record":{"id":"4604824053ced5de","repo":"pentaho/pentaho-kettle","slug":"the-function-call-escapexml-requires-1-argument","errorCode":null,"errorMessage":"The function call escapeXml requires 1 argument.","messagePattern":"The function call escapeXml requires 1 argument\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2712,"sourceCode":"        }\n\n        isValid = Boolean.TRUE;\n\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"Error in isMailValid function: \" + e.getMessage() );\n      }\n      return isValid;\n    } else {\n      throw Context.reportRuntimeError( \"The function call isMailValid is not valid\" );\n    }\n  }\n\n  public static String escapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.escapeXML( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call escapeXml requires 1 argument.\" );\n\n    }\n  }\n\n  public static String escapeHtml( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.escapeHtml( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call escapeHtml requires 1 argument.\" );\n    }\n  }\n\n  public static String unEscapeHtml( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.unEscapeHtml( Context.toString( ArgList[0] ) );\n    } else {","sourceCodeStart":2694,"sourceCodeEnd":2730,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2694-L2730","documentation":"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.","triggerScenarios":"Calling escapeXml() with no arguments, or escapeXml(a, b) with multiple arguments; ArgList.length != 1 hits the else branch and throws.","commonSituations":"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.","solutions":["Call escapeXml with exactly one string argument: escapeXml(myString)","Remove any extra options/flags arguments and use Const escaping defaults","Verify the script in the Modified Java Script Value dialog and test with a sample row"],"exampleFix":"// before\nvar safe = escapeXml(value, true);\n// after\nvar safe = escapeXml(value);","handlingStrategy":"validation","validationCode":"if (typeof value === 'string') { var safe = escapeXml(value); }","typeGuard":"function isString(v){ return typeof v === 'string'; }","tryCatchPattern":"try { var safe = escapeXml(value); } catch (e) { throw new Error('escapeXml requires exactly 1 argument: ' + e.message); }","preventionTips":["Never pass options/flags to Kettle built-in string functions","Verify argument count after editing scripts","Use the step's function documentation tree for signatures"],"tags":["javascript","xml","argument-count","pentaho-kettle"],"backgroundTag":"missing-required-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}