pentaho/pentaho-kettle · error · KettleValueException
Script.Log.UnexpectedeError
Script.Log.UnexpectedeError
Error message
Script.Log.UnexpectedeError
What it means
Thrown in Script.addValues when preparing the row values for the script fails. Before evaluating the main script, the step places the row's field values, result variables, and the rowMeta into the JS scope inside a try block; any Exception in that setup is wrapped in a KettleValueException with this generic 'Unexpected error' message. It means scope population failed before the script even ran.
Solutions
- Inspect the wrapped cause to identify which field/value failed to convert.
- Fix upstream step/field type mismatches (check the row layout with 'Show input fields').
- Null-handle or convert problematic fields before this step (e.g. with a Value Mapper or If Null step).
- Verify no upstream step changes the row structure mid-run (dynamic field changes).
Example fix
// before: upstream emits a custom object in field 'payload' // after: add a step to serialize it first, or emit a String strPayload = JSON.stringify(payload);
Defensive patterns
Strategy: validation
Validate before calling
// verify declared fields match actual input rows before the run
RowMetaInterface input = transMeta.getPrevStepFields(stepMeta);
for (String f : expectedFields) {
if (input.indexOfValue(f) < 0) {
throw new IllegalStateException("Expected field missing: " + f);
}
} Try / catch
try {
step.processRow();
} catch (KettleValueException e) {
if (e.getMessage().contains("UnexpectedeError")) {
logError("Scope setup failed, inspect cause: " + e.getCause(), e);
} else { throw e; }
} Prevention
- Null-check / sanitize data before the script step.
- Avoid upstream steps that mutate the row layout mid-run.
- Use standard Kettle value types; avoid custom object fields feeding the script.
- Preview rows at this step to confirm metadata matches data.
When it happens
Trigger: addValues (called from processRow): while populating data.scope with the row's fields and putting "rowMeta" into the scope, any Exception occurs (e.g. converting a field value into a JS-compatible object fails).
Common situations: Fields with data types the JS binding cannot convert (unusual objects, nulls with unexpected metadata); mismatch between row data and row metadata (misaligned upstream steps); custom value type plugins breaking conversion.
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
- AnalyticQueryMeta.Exception.SubjectFieldNotFound
- BaseStep.SafeMode.Exception.DoubleFieldnames
- BaseStep.SafeMode.Exception.MixingLayout
- BaseStep.SafeMode.Exception.MixingStorageTypes
- BaseStep.SafeMode.Exception.MixingTypes
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/33cab36f371b4c52.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java:306
int outputIndex = rowMeta.size();
try {
try {
data.scope.put( "row", row );
for ( int i = 0; i < data.fields_used.length; i++ ) {
ValueMetaInterface valueMeta = rowMeta.getValueMeta( data.fields_used[ i ] );
Object valueData = row[ data.fields_used[ i ] ];
Object normalStorageValueData = valueMeta.convertToNormalStorageType( valueData );
data.scope.put( valueMeta.getName(), normalStorageValueData );
}
// also add the meta information for the hole row
//
data.scope.put( "rowMeta", rowMeta );
} catch ( Exception e ) {
throw new KettleValueException( BaseMessages.getString( PKG, "Script.Log.UnexpectedeError" ), e );
}
data.script.eval( data.scope );
if ( bFirstRun ) {
bFirstRun = false;
// Check if we had a Transformation Status
Object tran_stat = data.scope.get( "trans_Status" );
if ( tran_stat != null ) { // TODO AKRETION not sure: !=
// ScriptableObject.NOT_FOUND
bWithTransStat = true;
if ( log.isDetailed() ) {
logDetailed( ( "tran_Status found. Checking transformation status while script execution." ) );
}
} else {
if ( log.isDetailed() ) {
logDetailed( ( "No tran_Status found. Transformation status checking not available." ) );
}View on GitHub (pinned to f3058517a1)