pentaho/pentaho-kettle · error · KettleValueException

ScriptValuesMod.Log.CouldNotCompileJavascript

Error message

ScriptValuesMod.Log.CouldNotCompileJavascript

What it means

Thrown when the main transform script (strTransformScript) cannot be compiled by the embedded Rhino JavaScript engine. addValues() calls data.cx.compileString(strTransformScript, "script", 1, null) and wraps any compilation Exception in a KettleValueException with this message. This is a parse/syntax-time failure, not a runtime script error.

Solutions

  1. Read the 'Caused by' EvaluatorException for the exact line/column of the syntax error
  2. Fix the syntax error in the script editor of the step
  3. Replace ES6+ constructs with ES5 equivalents compatible with the bundled Rhino version
  4. Check for invisible/non-ASCII characters and retype the problematic line
  5. Validate the script externally in a plain JS parser before pasting it back

Example fix

// before: ES6 syntax fails to compile in Rhino
const sum = (a, b) => a + b;
// after: ES5-compatible
var sum = function( a, b ) { return a + b; };
Defensive patterns

Strategy: validation

Validate before calling

// Check for common ES6 tokens unsupported by old Rhino before compiling
function isRhinoSafe(src) {
  return !/\b(let|const|=>|`|\.\.\.)\b?/.test(src);
}

Try / catch

try {
  runTransformation();
} catch ( KettleValueException e ) {
  if ( e.getCause() != null && e.getCause().getClass().getSimpleName().contains( "Evaluator" ) ) {
    logError( "Syntax error in transform script: " + e.getCause().getMessage() );
  }
  throw e;
}

Prevention

When it happens

Trigger: compileString() throws a Rhino EvaluatorException (syntax error) while compiling the main script text entered in the Modified Java Script Value step, during addValues() from processRow.

Common situations: JavaScript syntax errors (missing braces/semicolons), ES6+ syntax unsupported by old Rhino (let, const, arrow functions, template literals), stray non-ASCII characters pasted from editors, or Java-style code pasted into the JS editor.

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/1febcc7d37b41b57. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java:314

            startScript.exec( data.cx, data.scope );
            if ( log.isDetailed() ) {
              logDetailed( ( "Start Script found!" ) );
            }
          } else {
            if ( log.isDetailed() ) {
              logDetailed( ( "No starting Script found!" ) );
            }
          }
        } catch ( Exception es ) {
          // System.out.println("Exception processing StartScript " + es.toString());
          throw new KettleValueException( BaseMessages.getString(
            PKG, "ScriptValuesMod.Log.ErrorProcessingStartScript" ), es );

        }
        // Now Compile our Script
        data.script = data.cx.compileString( strTransformScript, "script", 1, null );
      } catch ( Exception e ) {
        throw new KettleValueException( BaseMessages.getString(
          PKG, "ScriptValuesMod.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();

    // Keep track of the changed values...
    //
    final Map<Integer, Value> usedRowValues;

    if ( meta.isCompatible() ) {
      usedRowValues = new Hashtable<Integer, Value>();
    } else {

View on GitHub (pinned to f3058517a1)