{"record":{"id":"f7face96c32c8072","repo":"pentaho/pentaho-kettle","slug":"the-function-call-initcap-requires-1-argument","errorCode":null,"errorMessage":"The function call initCap requires 1 argument.","messagePattern":"The function call initCap 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":2780,"sourceCode":"    }\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] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call removeDigits requires 1 argument.\" );\n\n    }\n  }\n\n  public static String initCap( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.initCap( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call initCap requires 1 argument.\" );\n\n    }\n  }\n\n  public static Object loadFileContent( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    Object oRC = new Object();\n    try {\n\n      switch ( ArgList.length ) {\n        case 0:\n          throw Context.reportRuntimeError( \"Please provide a filename to the function call loadFileContent.\" );\n        case 1:\n          try {\n            if ( isNull( ArgList ) ) {\n              return null;\n            } else if ( isUndefined( ArgList ) ) {\n              return Context.getUndefinedValue();","sourceCodeStart":2762,"sourceCodeEnd":2798,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2762-L2798","documentation":"initCap capitalizes the first letter of each word via Const.initCap in the Modified Java Script Value step. This error is thrown when the function is invoked with an argument count other than exactly 1 — only a single string input is supported.","triggerScenarios":"initCap() with zero arguments or initCap(s, extra) with multiple arguments; ArgList.length != 1 reaches the else branch and throws.","commonSituations":"Users attempting to pass a locale as a second argument; scripts where the field argument was removed leaving an empty call.","solutions":["Call initCap with exactly one argument: initCap(nameField)","Remove extra parameters such as locale (unsupported)","Handle null/undefined fields before calling to avoid other JS errors"],"exampleFix":"// before\nvar capped = initCap(name, \"en\");\n// after\nvar capped = initCap(name);","handlingStrategy":"validation","validationCode":"if (typeof name === 'string' && name.length > 0) { var capped = initCap(name); }","typeGuard":"function isNonEmptyString(v){ return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { var capped = initCap(name); } catch (e) { throw new Error('initCap requires exactly 1 argument: ' + e.message); }","preventionTips":["Never pass locale or option parameters","Verify field variables resolve at runtime","Keep scripts minimal and test per row"],"tags":["javascript","string","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"}