{"record":{"id":"2cfc24318a0495d9","repo":"pentaho/pentaho-kettle","slug":"the-function-call-escapesql-requires-1-argument","errorCode":null,"errorMessage":"The function call escapeSQL requires 1 argument.","messagePattern":"The function call escapeSQL 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":2750,"sourceCode":"    }\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] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call protectXMLCDATA requires 1 argument.\" );\n\n    }\n  }\n\n  public static String removeDigits( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.removeDigits( Context.toString( ArgList[0] ) );","sourceCodeStart":2732,"sourceCodeEnd":2768,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2732-L2768","documentation":"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.","triggerScenarios":"escapeSQL() with no arguments, or escapeSQL(s, extra) with additional arguments; the length==1 guard fails and Context.reportRuntimeError fires.","commonSituations":"Users passing a connection or dialect as a second argument; accidentally deleting the argument variable so the array is empty.","solutions":["Call escapeSQL with exactly one string argument: escapeSQL(sqlFragment)","Prefer parameterized queries over string escaping for actual SQL safety","Verify the argument is not null/empty before calling"],"exampleFix":"// before\nvar safe = escapeSQL(value, connection);\n// after\nvar safe = escapeSQL(value);","handlingStrategy":"validation","validationCode":"if (typeof sqlFragment === 'string' && sqlFragment.length > 0) { var safe = escapeSQL(sqlFragment); }","typeGuard":"function isNonEmptyString(v){ return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { var safe = escapeSQL(sqlFragment); } catch (e) { throw new Error('escapeSQL requires exactly 1 argument: ' + e.message); }","preventionTips":["Pass only the string to escape; use parameters for connections","Prefer prepared statements over string escaping","Guard against null fields before calling"],"tags":["javascript","sql","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"}