pentaho/pentaho-kettle · error · KettleValueException
Script.Log.CouldNotCompileJavascript
Script.Log.CouldNotCompileJavascript
Error message
Script.Log.CouldNotCompileJavascript
What it means
Thrown in Script.addValues when compilation of the main transform script fails. The step casts its JS engine context to javax.script.Compilable and calls compile(strTransformScript); any Exception (most commonly a script syntax error) is wrapped in a KettleValueException with this message. The transformation cannot proceed because the script never compiles.
Solutions
- Use the step's 'Test script' button to locate and fix the JavaScript syntax error.
- Check the wrapped cause for the exact line/column of the parse error.
- Remove pasted artifacts (smart quotes, HTML) and retype the offending line.
- Confirm the script targets the JSR-223 compliant engine shipped with your Pentaho version.
Example fix
// before var total = price * ; // after var total = price * quantity;
Defensive patterns
Strategy: validation
Validate before calling
// pre-compile the script to catch syntax errors before the run
try {
new javax.script.ScriptEngineManager().getEngineByName("ECMAScript").eval(strTransformScript);
} catch (ScriptException se) {
throw new IllegalStateException("Transform script syntax error: " + se.getMessage());
} Try / catch
try {
step.processRow();
} catch (KettleValueException e) {
if (e.getMessage().contains("CouldNotCompileJavascript")) {
logError("Fix transform script syntax: " + e.getCause().getMessage());
} else { throw e; }
} Prevention
- Always use the Test script button before saving/running.
- Avoid pasting from rich-text editors (smart quotes, invisible characters).
- Write engine-portable JavaScript (no Rhino-only extensions when using JSR-223).
- Lint the script in an external editor for early syntax detection.
When it happens
Trigger: addValues (called from processRow): ((Compilable) data.cx).compile(strTransformScript) throws, typically a ScriptSyntaxError from malformed JavaScript in the transform script tab; it fires on the first processed row (script compiled lazily on first use).
Common situations: Typos/syntax errors in the transform script; using Rhino-only syntax not accepted by the JSR-223 engine; non-ASCII characters or smart quotes pasted from editors; scripts referencing Pentaho-specific globals are fine, but stray HTML/XML pasted into the editor is not.
Related errors
- ScriptValuesMod.Log.CouldNotCompileJavascript
- Could not convert the given String :
- e.toString()
- Please provide a valid Char to the fillString
- Script.Log.CouldNotAddDefaultConstants
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/a5bf4e4284deb8e5.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java:279
logDetailed( ( "No starting Script found!" ) );
}
}
} catch ( Exception es ) {
// System.out.println("Exception processing StartScript " +
// es.toString());
throw new KettleValueException(
BaseMessages.getString( PKG, "Script.Log.ErrorProcessingStartScript" ), es );
}
// Now Compile our Script
// alternatively you could also support non compilable JSR223
// languages, see how we were doing before:
// http://github.com/rvalyi/jripple/blob/e6190fd89014a49b0faffae68c75762be124d899/
// src/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java
data.script = ( (Compilable) data.cx ).compile( strTransformScript );
} catch ( Exception e ) {
throw new KettleValueException( BaseMessages.getString( PKG, "Script.Log.CouldNotCompileJavascript" ), e );
}
}
// Filling the defined TranVars with the Values from the Row
//
Object[] outputRow = RowDataUtil.resizeArray( row, data.outputRowMeta.size() );
// Keep an index...
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 ] ];
View on GitHub (pinned to f3058517a1)