{"record":{"id":"8f6380b42cf59848","repo":"pentaho/pentaho-kettle","slug":"the-function-call-lower-is-not-valid-e-getmessage","errorCode":null,"errorMessage":"The function call lower is not valid : \" + e.getMessage()","messagePattern":"The function call lower is not valid : \" \\+ e\\.getMessage\\(\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java","lineNumber":1286,"sourceCode":"      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() );\n      }\n    } else {\n      throw new RuntimeException( \"The function call lower requires 1 argument.\" );\n    }\n    return sRC;\n  }\n\n  // Converts the given Numeric to a JScript String\n  public static String num2str( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,\n    Object FunctionContext ) {\n    String sRC = \"\";\n    switch ( ArgList.length ) {\n      case 0:\n        throw new RuntimeException( \"The function call num2str requires at least 1 argument.\" );\n      case 1:\n        try {\n          if ( isNull( ArgList[0] ) ) {\n            return null;","sourceCodeStart":1268,"sourceCodeEnd":1304,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java#L1268-L1304","documentation":"Failure path in ScriptAddedFunctions.lower: an exception was caught while lower-casing ArgList[0] — most commonly a ClassCastException because the argument is not a String — and it is rethrown as a RuntimeException with the caught message appended. (The recorded message string itself contains a literal concatenation typo from the source.)","triggerScenarios":"Calling lower(x) where x is not a String (e.g. a number, Date, or Java object), causing the cast/conversion inside the try block to throw, wrapped with this message.","commonSituations":"Passing a numeric key or date field directly; locale-sensitive value objects from earlier Java steps leaking into the script.","solutions":["Coerce to string first: lower('' + myField) or use str/num2str conversion.","Ensure the incoming field is typed as String (use a 'Select values' step before the Script).","Read the wrapped e.getMessage() for the concrete cause."],"exampleFix":"// before\nlower(accountId)\n// after\nlower('' + accountId)","handlingStrategy":"type-guard","validationCode":"function safeLower(v) { return (v === null || v === undefined) ? null : lower(String(v)); }","typeGuard":"function isString(v) { return typeof v === 'string' || v instanceof java.lang.String; }","tryCatchPattern":"try { return lower(v); }\ncatch (e) { if (/lower is not valid/.test(e.message)) return String(v).toLowerCase(); throw e; }","preventionTips":["Coerce non-strings with String(v) before calling lower().","Type incoming fields as String in a preceding transform.","Avoid passing Java objects from earlier steps directly into string helpers."],"tags":["javascript","scripting-step","string","type-mismatch"],"backgroundTag":"type-mismatch","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"}