{"record":{"id":"3ed09dc180c2dd84","repo":"pentaho/pentaho-kettle","slug":"the-function-call-isempty-is-not-valid","errorCode":null,"errorMessage":"The function call isEmpty is not valid","messagePattern":"The function call isEmpty is not valid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":2672,"sourceCode":"    if ( ArgList.length == 1 ) {\n      try {\n        if ( isUndefined( ArgList[0] ) ) {\n          throw new Exception( ArgList[0] + \" is  undefined!\" );\n        }\n        if ( isNull( ArgList[0] ) ) {\n          return Boolean.TRUE;\n        }\n        if ( Context.toString( ArgList[0] ).length() == 0 ) {\n          return Boolean.TRUE;\n        } else {\n          return Boolean.FALSE;\n        }\n\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"Error in isEmpty function: \" + e.getMessage() );\n      }\n    } else {\n      throw Context.reportRuntimeError( \"The function call isEmpty is not valid\" );\n    }\n  }\n\n  public static Boolean isMailValid( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    Boolean isValid;\n    if ( ArgList.length == 1 ) {\n      try {\n        if ( isUndefined( ArgList[0] ) ) {\n          throw new Exception( ArgList[0] + \" is  undefined!\" );\n        }\n        if ( isNull( ArgList[0] ) ) {\n          return Boolean.FALSE;\n        }\n        if ( Context.toString( ArgList[0] ).length() == 0 ) {\n          return Boolean.FALSE;\n        }\n","sourceCodeStart":2654,"sourceCodeEnd":2690,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2654-L2690","documentation":"isEmpty(value) requires exactly one argument. When the JS call's argument list does not match the expected signature (wrong count), the code short-circuits to this 'not valid' runtime error before attempting the emptiness check. It is a signature-validation failure, distinct from the wrapped internal 'Error in isEmpty function:' message.","triggerScenarios":"isEmpty() with zero arguments, isEmpty(a, b) with extra arguments, or a call where ArgList length fails the function's check in the Modified Java Script Value step.","commonSituations":"Undefined variable making the call site look malformed; copy-paste of ISNULL/ISempty variants from other engines with different arities; refactors leaving stale extra parameters.","solutions":["Call isEmpty with exactly one argument: isEmpty(fieldName).","Guard: if (typeof fieldName != 'undefined' && fieldName != null) { ... }.","Use JS length checks yourself if you need multi-value emptiness: isEmpty(a) || isEmpty(b).","Fix variable name typos that leave the expression evaluating with wrong arity."],"exampleFix":"// before\nvar e = isEmpty(a, b);\n// after\nvar e = isEmpty(a) || isEmpty(b);","handlingStrategy":"validation","validationCode":"function safeIsEmpty1(v) { if (typeof v === 'undefined') return true; try { return isEmpty(v); } catch (e) { return true; } }","typeGuard":"function hasOneArg(v) { return typeof v !== 'undefined' && v !== null; }","tryCatchPattern":"try { e = isEmpty(val); } catch (ex) { if (ex.message.indexOf('not valid') >= 0) { e = true; } else { throw ex; } }","preventionTips":["Call with exactly one argument","Replace removed extra parameters after refactors","Check variable names for typos that break the call arity"],"tags":["javascript","scripting","argument-count","rhino"],"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"}