{"record":{"id":"3a70b605a423c2e3","repo":"pentaho/pentaho-kettle","slug":"the-function-call-unescapexml-requires-1-argument","errorCode":null,"errorMessage":"The function call unEscapeXml requires 1 argument.","messagePattern":"The function call unEscapeXml requires 1 argument\\.","errorType":"exception","errorClass":"Rhino runtime error","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2740,"sourceCode":"      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 {\n      throw Context.reportRuntimeError( \"The function call unEscapeHtml requires 1 argument.\" );\n    }\n  }\n\n  public static String unEscapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.unEscapeXml( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call unEscapeXml requires 1 argument.\" );\n\n    }\n  }\n\n  public static String escapeSQL( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.escapeSQL( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call escapeSQL requires 1 argument.\" );\n\n    }\n  }\n\n  public static String protectXMLCDATA( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.protectXMLCDATA( Context.toString( ArgList[0] ) );","sourceCodeStart":2722,"sourceCodeEnd":2758,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2722-L2758","documentation":"unEscapeXml reverses XML escaping via Const.unEscapeXml in the Modified Java Script Value step. This error is thrown when the function is invoked with an argument count other than exactly 1, because the wrapper requires a single string input.","triggerScenarios":"unEscapeXml() with zero arguments or unEscapeXml(a, b) with extra arguments; ArgList.length != 1 reaches the else branch and throws.","commonSituations":"Scripts migrated from other engines whose unEscapeXml takes a second flag; users attempting to pass an encoding name as a second parameter.","solutions":["Call unEscapeXml with exactly one argument: unEscapeXml(xmlString)","Drop any extra parameters (encoding, flags are unsupported)","Check the function reference in the Modified Java Script Value step"],"exampleFix":"// before\nvar raw = unEscapeXml(xml, \"UTF-8\");\n// after\nvar raw = unEscapeXml(xml);","handlingStrategy":"validation","validationCode":"if (typeof xml === 'string') { var raw = unEscapeXml(xml); }","typeGuard":"function isString(v){ return typeof v === 'string'; }","tryCatchPattern":"try { var raw = unEscapeXml(xml); } catch (e) { throw new Error('unEscapeXml requires exactly 1 argument: ' + e.message); }","preventionTips":["Do not pass encoding or flag parameters","Confirm argument count in the step dialog","Test scripts on a single row first"],"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"}