pentaho/pentaho-kettle · error · KettleValueException
Script.Log.JavascriptError
Script.Log.JavascriptError
Error message
Script.Log.JavascriptError
What it means
Thrown in Script.addValues when the main transform script's evaluation throws a javax.script.ScriptException. After the scope is prepared, data.script.eval(data.scope) runs the user's JavaScript; any error raised inside the script (runtime error, thrown JS exception, undefined function call) surfaces as this KettleValueException. This is the standard failure path for buggy transform scripts.
Solutions
- Read the wrapped ScriptException's line number/message to find the failing script line.
- Add null/undefined checks around field access in the script.
- Guard row-dependent logic with conditionals so rows missing fields don't crash the run.
- Use the step's Test script feature with sample data reproducing the failing row.
Example fix
// before var v = strField.toUpperCase(); // after var v = (strField != null) ? strField.toUpperCase() : null;
Defensive patterns
Strategy: try-catch
Validate before calling
// defensive script skeleton to run before trusting rows:
// if (typeof someField == "undefined" || someField == null) { someField = defaultValue; } Type guard
function isDefined(v) { return typeof v !== "undefined" && v !== null; } Try / catch
try {
step.processRow();
} catch (KettleValueException e) {
if (e.getMessage().contains("JavascriptError") || e.getCause() instanceof ScriptException) {
logError("Script runtime error: " + e.getCause().getMessage());
putError(...); // route row to error handling instead of failing
} else { throw e; }
} Prevention
- Guard every field access for null/undefined.
- Do not rely on engine-specific functions (check Rhino vs Nashorn support).
- Enable step error handling to divert bad rows instead of aborting.
- Test the script with edge-case data (nulls, empty strings, zero).
When it happens
Trigger: addValues (called from processRow): data.script.eval(data.scope) throws a ScriptException — e.g. calling an undefined function, accessing a property of an undefined variable, or the script explicitly throwing — on any row being processed.
Common situations: Scripts referencing fields not present on some rows (null handling mistakes); calling functions that don't exist in this engine (Rhino vs Nashorn differences); division by zero or type coercion errors on dirty data; using Java imports unavailable in the sandbox.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Could not convert the given String :
- e.toString()
- Please provide a valid Char to the fillString
- Script.Log.CouldNotAddDefaultConstants
- Script.Log.CouldNotAttachAdditionalScripts
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/8a47e6a12940681b.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java:386
break;
case ERROR_TRANSFORMATION:
if ( data.cx != null ) {
// Context.exit(); TODO AKRETION not sure
setErrors( 1 );
}
stopAll();
bRC = false;
break;
default:
break;
}
// TODO: kick this "ERROR handling" junk out now that we have
// solid error handling in place.
//
}
} catch ( ScriptException e ) {
throw new KettleValueException( BaseMessages.getString( PKG, "Script.Log.JavascriptError" ), e );
}
return bRC;
}
public Object getValueFromJScript( Object result, int i ) throws KettleValueException {
String fieldName = meta.getFieldname()[ i ];
if ( !Utils.isEmpty( fieldName ) ) {
// res.setName(meta.getRename()[i]);
// res.setType(meta.getType()[i]);
try {
return ( result == null ) ? null
: JavaScriptUtils.convertFromJs( result, meta.getType()[ i ], fieldName );
} catch ( Exception e ) {
throw new KettleValueException( BaseMessages.getString( PKG, "Script.Log.JavascriptError" ), e );
}
} else {
throw new KettleValueException( "No name was specified for result value #" + ( i + 1 ) );View on GitHub (pinned to f3058517a1)