{"record":{"id":"7120c1516226408a","repo":"pentaho/pentaho-kettle","slug":"the-function-call-ismailvalid-is-not-valid","errorCode":null,"errorMessage":"The function call isMailValid is not valid","messagePattern":"The function call isMailValid 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":2703,"sourceCode":"          return Boolean.FALSE;\n        }\n        if ( Context.toString( ArgList[0] ).length() == 0 ) {\n          return Boolean.FALSE;\n        }\n\n        String email = Context.toString( ArgList[0] );\n        if ( email.indexOf( '@' ) == -1 || email.indexOf( '.' ) == -1 ) {\n          return Boolean.FALSE;\n        }\n\n        isValid = Boolean.TRUE;\n\n      } catch ( Exception e ) {\n        throw Context.reportRuntimeError( \"Error in isMailValid function: \" + e.getMessage() );\n      }\n      return isValid;\n    } else {\n      throw Context.reportRuntimeError( \"The function call isMailValid is not valid\" );\n    }\n  }\n\n  public static String escapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.escapeXML( Context.toString( ArgList[0] ) );\n    } else {\n      throw Context.reportRuntimeError( \"The function call escapeXml requires 1 argument.\" );\n\n    }\n  }\n\n  public static String escapeHtml( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    if ( ArgList.length == 1 ) {\n      return Const.escapeHtml( Context.toString( ArgList[0] ) );\n    } else {","sourceCodeStart":2685,"sourceCodeEnd":2721,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L2685-L2721","documentation":"In Pentaho Kettle's JavaScript scripting (ScriptValuesMod / Modified Java Script Value step), the isMailValid JS function validates an email address. This Rhino RuntimeControlError is thrown when the function is invoked with the wrong number of arguments, so the implementation skips its logic and reports that the call itself 'is not valid'. It is a scripting-layer misuse of a built-in JS helper, not a mail server failure.","triggerScenarios":"Calling isMailValid() with zero arguments, or with more than the expected single email argument inside a Modified Java Script Value step; the arg-count branch falls to the else and throws via Context.reportRuntimeError.","commonSituations":"Users pasting old scripts that call isMailValid with 2 args (email + pattern) after a Kettle upgrade changed the signature; typos passing no argument; concatenating arguments so the arg array is empty.","solutions":["Call isMailValid with exactly one argument, e.g. isMailValid(emailField)","Check the function signature in ScriptValuesAddedFunctions.java and the Kettle JS function docs for your version","Wrap the call in try/catch in the JS script to surface a friendlier message","If a two-arg variant is needed, upgrade/downgrade to a Kettle version that supports it or implement regex validation inline"],"exampleFix":"// before\nvar ok = isMailValid(email, \"@company.com\");\n// after\nvar ok = isMailValid(email);","handlingStrategy":"validation","validationCode":"if (typeof email === 'string' && email.length > 0) { var ok = isMailValid(email); } else { var ok = false; }","typeGuard":"function isNonEmptyString(v){ return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { var ok = isMailValid(email); } catch (e) { throw new Error('isMailValid call failed: ' + e.message); }","preventionTips":["Always call built-in JS functions with the documented argument count","Test the script against one sample row before running the full transformation","Check the function list in the Modified Java Script Value step for signatures","Wrap risky script helpers in try/catch to fail with context"],"tags":["javascript","scripting","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"}