{"record":{"id":"043fc7a024c6f3a4","repo":"pentaho/pentaho-kettle","slug":"the-function-call-upper-is-not-valid-e-getmessage-043fc7","errorCode":null,"errorMessage":"The function call upper is not valid : {e.getMessage()}","messagePattern":"The function call upper is not valid : (.+?)","errorType":"exception","errorClass":"JavaScriptException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1299,"sourceCode":"    } else {\n      throw Context.reportRuntimeError( \"The function call sendMail requires 5 arguments.\" );\n    }\n  }\n\n  public static String upper( 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 = sRC.toUpperCase();\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"The function call upper is not valid : \" + e.getMessage() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call upper requires 1 argument.\" );\n    }\n    return sRC;\n  }\n\n  public static String lower( 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] );","sourceCodeStart":1281,"sourceCodeEnd":1317,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1281-L1317","documentation":"Thrown by the upper() JavaScript function when converting its single argument to a string and uppercasing it fails. Any exception in that block is caught and re-thrown as 'The function call upper is not valid : ' + e.getMessage(). This is typically caused by an argument that Context.toString() cannot handle or an unexpected runtime condition inside the Rhino context.","triggerScenarios":"Calling upper(x) where x is an object with no meaningful string coercion that throws, or internal conversion failures during Context.toString(ArgList[0]) — essentially any exception thrown inside the try block for a single-argument call.","commonSituations":"Passing null-filled row fields whose JavaScript representation trips conversion; passing complex objects (arrays of rows, NativeJavaObject wrappers) instead of scalars; Rhino context differences across Kettle versions.","solutions":["Pass a plain string or scalar: upper(String(fieldName)).","Check the e.getMessage() suffix — it identifies the exact conversion failure.","Handle nulls before the call: if (field == null) result = null; else result = upper(field).","Unwrap Java objects with Context.toString or String() before applying upper."],"exampleFix":"// before\nvar u = upper(rowObject)\n// after\nvar u = (rowObject == null) ? null : upper(String(rowObject.someField))","handlingStrategy":"type-guard","validationCode":"// JS\nfunction safeUpper(v) { return (v == null) ? null : upper(String(v)); }","typeGuard":"function isStringLike(v) { return typeof v === 'string' || typeof v === 'number'; }","tryCatchPattern":"try { u = upper(v); } catch (e) { u = null; logError(\"upper failed: \" + e.message); }","preventionTips":["Pass scalars, not row objects or Java wrappers","Null-check before calling upper","Coerce with String() first for exotic values","Read the e.getMessage() suffix to identify conversion issues"],"tags":["javascript","string","pentaho-kettle"],"backgroundTag":"invalid-argument-value","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"}