pentaho/pentaho-kettle · error
Error in isEmpty function:
Error message
Error in isEmpty function:
What it means
isEmpty(value) tests whether a string/value is empty. This handler wraps any unexpected exception thrown while evaluating the check (e.g. operating on an object type it cannot handle) and rethrows it as a Rhino runtime error prefixed with 'Error in isEmpty function: '. The suffix message from e.getMessage() identifies the underlying cause.
Solutions
- Convert the argument to string first: isEmpty(value == null ? '' : value.toString()).
- Null-check before the call since the wrapped helper may not accept all null shapes in your version.
- Read the e.getMessage() suffix in the error to identify the actual failing operation.
- Normalize field types in a prior step (Select values / type cast) before scripting.
Example fix
// before var e = isEmpty(myBigDec) ; // after var e = isEmpty(myBigDec == null ? '' : myBigDec.toString());
Defensive patterns
Strategy: type-guard
Validate before calling
function safeIsEmpty(v) { if (v == null) return true; try { return isEmpty(v.toString()); } catch (e) { return false; } } Type guard
function isStringish(v) { return v == null || typeof v === 'string' || (v != null && typeof v.toString === 'function'); } Try / catch
try { e = isEmpty(val); } catch (ex) { Logger.LogError('isEmpty failed: ' + ex.message); e = true; /* treat as empty */ } Prevention
- Convert non-string fields with toString() before checking
- Cast field types in a preceding Select values step
- Keep the e.getMessage() suffix when logging for root cause
When it happens
Trigger: Calling isEmpty with a value whose evaluation throws — e.g. certain non-string Java objects passed from previous steps, or conversion failures on the argument inside the try block while the argument count itself was valid.
Common situations: Passing a Java object (e.g. BigDecimal, binary field) rather than a string; null-plus-method-chain mistakes nearby; upstream field type changes after transformation edits.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Could not convert to local format.
- Could not convert to the given format.
- ScriptValuesMod.Log.CouldNotAddDefaultConstants
- The function call getLastModifiedTime is not valid.
- The function call isEmpty is not valid
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/e50890f894180f7e.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:2669
public static Boolean isEmpty( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
if ( ArgList.length == 1 ) {
try {
if ( isUndefined( ArgList[0] ) ) {
throw new Exception( ArgList[0] + " is undefined!" );
}
if ( isNull( ArgList[0] ) ) {
return Boolean.TRUE;
}
if ( Context.toString( ArgList[0] ).length() == 0 ) {
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
} catch ( Exception e ) {
throw Context.reportRuntimeError( "Error in isEmpty function: " + e.getMessage() );
}
} else {
throw Context.reportRuntimeError( "The function call isEmpty is not valid" );
}
}
public static Boolean isMailValid( Context actualContext, Scriptable actualObject, Object[] ArgList,
Function FunctionContext ) {
Boolean isValid;
if ( ArgList.length == 1 ) {
try {
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 ) {View on GitHub (pinned to f3058517a1)