{"record":{"id":"0f82d12bb8647970","repo":"pentaho/pentaho-kettle","slug":"the-function-call-upper-requires-1-argument","errorCode":null,"errorMessage":"The function call upper requires 1 argument.","messagePattern":"The function call upper requires 1 argument\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":1268,"sourceCode":"  }\n\n  public static String upper( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object 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) undefinedValue;\n        }\n        sRC = (String) ArgList[0];\n        sRC = sRC.toUpperCase();\n      } catch ( Exception e ) {\n        throw new RuntimeException( \"The function call upper is not valid : \" + e.getMessage() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call upper requires 1 argument.\" );\n    }\n    return sRC;\n  }\n\n  public static String lower( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object 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) undefinedValue;\n        }\n        sRC = (String) ArgList[0];\n        sRC = sRC.toLowerCase();\n      } catch ( Exception e ) {\n        throw new RuntimeException( \"The function call lower is not valid : \" + e.getMessage() );","sourceCodeStart":1250,"sourceCodeEnd":1286,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1250-L1286","documentation":"Arity guard in ScriptAddedFunctions.upper: the script call supplied an argument list whose length is not 1. The single expected argument is a String to upper-case (null returns null); with any other count the RuntimeException is thrown to the script engine.","triggerScenarios":"upper() called with 0 arguments or 2+ arguments, e.g. upper(first, last).","commonSituations":"Attempting C-style multi-arg concatenation; forgetting the argument after a refactor; passing extra options that the function does not accept.","solutions":["Call upper with exactly one string argument.","Concatenate first, then uppercase: upper(a + ' ' + b)."],"exampleFix":"// before\nupper(firstName, lastName)\n// after\nupper(firstName + ' ' + lastName)","handlingStrategy":"validation","validationCode":"function safeUpper(v) { if (arguments.length !== 1) throw new Error('upper needs exactly 1 argument'); return upper(v); }","typeGuard":null,"tryCatchPattern":"try { return upper(v); }\ncatch (e) { if (/requires 1 argument/.test(e.message)) return null; throw e; }","preventionTips":["One field per upper() call; combine strings before or after, not inside.","Review scripts after refactoring to ensure arguments were not dropped."],"tags":["javascript","scripting-step","argument-count","string"],"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"}