pentaho/pentaho-kettle · error

Error in isMailValid function:

Error message

Error in isMailValid function: 

What it means

isMailValid(value) checks an email address format and returns a Boolean. Any exception during validation (conversion or pattern-check failure on the given value) is rethrown with this prefix and the underlying message appended. The value must be convertible to a string for the regex/format test to run.

Solutions

  1. Coerce and null-check first: var ok = (email != null) && isMailValid(email.toString()).
  2. Validate the field is a String in a prior step (Select values type cast).
  3. Treat null emails separately from invalid emails in your logic.
  4. Inspect the appended e.getMessage() to pinpoint the conversion that failed.

Example fix

// before
var ok = isMailValid(emailField); // may throw when null
// after
var ok = (emailField != null) && isMailValid(emailField.toString());
Defensive patterns

Strategy: validation

Validate before calling

function safeMailCheck(v) { if (v == null) return false; try { return isMailValid(v.toString()); } catch (e) { return false; } }

Type guard

function isEmailString(v) { return typeof v === 'string' && v.length > 0; }

Try / catch

try { ok = isMailValid(email); } catch (e) { Logger.LogError('isMailValid failed: ' + e.message); ok = false; }

Prevention

When it happens

Trigger: Calling isMailValid with a null or non-convertible value whose processing throws inside the try block, while the argument count is otherwise correct.

Common situations: Email field null from source data; field typed as non-string; internationalized/odd encodings breaking conversions; upstream step delivering binary instead of string.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/ee1471196f7d2832. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2699

        if ( isUndefined( ArgList[0] ) ) {
          throw new Exception( ArgList[0] + " is  undefined!" );
        }
        if ( isNull( ArgList[0] ) ) {
          return Boolean.FALSE;
        }
        if ( Context.toString( ArgList[0] ).length() == 0 ) {
          return Boolean.FALSE;
        }

        String email = Context.toString( ArgList[0] );
        if ( email.indexOf( '@' ) == -1 || email.indexOf( '.' ) == -1 ) {
          return Boolean.FALSE;
        }

        isValid = Boolean.TRUE;

      } catch ( Exception e ) {
        throw Context.reportRuntimeError( "Error in isMailValid function: " + e.getMessage() );
      }
      return isValid;
    } else {
      throw Context.reportRuntimeError( "The function call isMailValid is not valid" );
    }
  }

  public static String escapeXml( Context actualContext, Scriptable actualObject, Object[] ArgList,
    Function FunctionContext ) {
    if ( ArgList.length == 1 ) {
      return Const.escapeXML( Context.toString( ArgList[0] ) );
    } else {
      throw Context.reportRuntimeError( "The function call escapeXml requires 1 argument." );

    }
  }

  public static String escapeHtml( Context actualContext, Scriptable actualObject, Object[] ArgList,

View on GitHub (pinned to f3058517a1)