{"record":{"id":"24147a2817f297b1","repo":"pentaho/pentaho-kettle","slug":"the-function-call-trim-requires-1-argument-24147a","errorCode":null,"errorMessage":"The function call trim requires 1 argument.","messagePattern":"The function call trim requires 1 argument\\.","errorType":"exception","errorClass":"RhinoRuntimeError","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1650,"sourceCode":"  }\n\n  public static String trim( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    String sRC = \"\";\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return (String) Context.getUndefinedValue();\n        }\n        sRC = Context.toString( ArgList[0] );\n        sRC = Const.trim( sRC );\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"The function call trim is not valid : \" + e.getMessage() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call trim requires 1 argument.\" );\n    }\n    return sRC;\n  }\n\n  public static String substr( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    String sRC = \"\";\n\n    if ( ArgList.length == 2 ) {\n      try {\n        if ( isNull( ArgList[0] ) ) {\n          return null;\n        } else if ( isUndefined( ArgList[0] ) ) {\n          return (String) Context.getUndefinedValue();\n        }\n        sRC = Context.toString( ArgList[0] );\n        int from = (int) Math.round( Context.toNumber( ArgList[1] ) );\n        sRC = sRC.substring( from );","sourceCodeStart":1632,"sourceCodeEnd":1668,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1632-L1668","documentation":"Argument-count guard in ScriptValuesAddedFunctions.trim, which removes leading and trailing whitespace via Const.trim. It fires when the script calls trim with an argument count other than exactly 1; Rhino raises a runtime error before trimming. Fix by passing exactly one string argument, e.g. trim(name).","triggerScenarios":"Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1650 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call trim(value) with exactly one argument"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}