pentaho/pentaho-kettle · error · KettleStepException

ScriptValuesMetaMod.Exception.NumberFormatException

Error message

ScriptValuesMetaMod.Exception.NumberFormatException

What it means

When no explicit Rhino optimization level is set, ScriptValuesMod falls back to parsing ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT with Integer.parseInt(); a NumberFormatException is caught and rethrown as a KettleStepException with the message ScriptValuesMetaMod.Exception.NumberFormatException. It means the configured (or substituted) optimization-level value is not a valid integer.

Solutions

  1. Open the step's Optimization level field and set a plain integer (typically -1 for interpreted mode or 0/9 for Rhino levels).
  2. If a Kettle variable is used, verify it is defined (kettle.properties / transformation parameter) and resolves to digits only at runtime.
  3. Trim the value: remove spaces, quotes, or trailing characters; enter exactly one integer token.
  4. Remove any units or comments from the field; the parser accepts only [-+]?digits.

Example fix

// before (step dialog / ktr XML)
<optimizationLevel>${JS_OPT_LEVEL}</optimizationLevel>  <!-- variable undefined -> substitution empty -->
// after
<optimizationLevel>-1</optimizationLevel>  <!-- or define JS_OPT_LEVEL=-1 in kettle.properties -->
Defensive patterns

Strategy: validation

Validate before calling

// Java, validate the optimization level before building the step meta
String lvl = environmentSubstitute(meta.getOptimizationLevel());
if (lvl != null) {
  try { Integer.parseInt(lvl.trim()); }
  catch (NumberFormatException nfe) {
    throw new IllegalArgumentException("Optimization level must be an integer, got: '" + lvl + "'");
  }
}

Try / catch

try {
  transformation.execute(params);
} catch (KettleStepException e) {
  if (e.getMessage().contains("NumberFormatException")) {
    // fix the Optimization level field or the Kettle variable it references, retry
  } else { throw e; }
}

Prevention

When it happens

Trigger: environmentSubstitute(meta.getOptimizationLevel()) yields a string that Integer.parseInt() cannot parse — e.g. a variable like ${OPT_LEVEL} resolves to empty, non-numeric text, or contains whitespace/units, and the code attempts Integer.parseInt on the default/actual value inside addValues().

Common situations: Optimization level field left blank or containing a Kettle variable that is undefined at runtime (substitutes to empty or literal '${VAR}'); user typed '0.5' or '-1 fast' or a thousand-separated number; value comes from an environment variable set on a server with the wrong content.

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

Appendix: source

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

        }
      }

      // set the optimization level
      data.cx = ContextFactory.getGlobal().enterContext();

      try {
        String optimizationLevelAsString = environmentSubstitute( meta.getOptimizationLevel() );
        if ( !Utils.isEmpty( Const.trim( optimizationLevelAsString ) ) ) {
          data.cx.setOptimizationLevel( Integer.parseInt( optimizationLevelAsString.trim() ) );
          logBasic( BaseMessages.getString( PKG, "ScriptValuesMod.Optimization.Level", environmentSubstitute( meta
            .getOptimizationLevel() ) ) );
        } else {
          data.cx.setOptimizationLevel( Integer.parseInt( ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT ) );
          logBasic( BaseMessages.getString(
            PKG, "ScriptValuesMod.Optimization.UsingDefault", ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT ) );
        }
      } catch ( NumberFormatException nfe ) {
        throw new KettleStepException( BaseMessages.getString(
          PKG, "ScriptValuesMetaMod.Exception.NumberFormatException", environmentSubstitute( meta
            .getOptimizationLevel() ) ) );
      } catch ( IllegalArgumentException iae ) {
        throw new KettleException( iae.getMessage() );
      }

      data.scope = data.cx.initStandardObjects( null, false );

      bFirstRun = true;

      Scriptable jsvalue = Context.toObject( this, data.scope );
      data.scope.put( "_step_", data.scope, jsvalue );

      // Adding the existing Scripts to the Context
      for ( int i = 0; i < meta.getNumberOfJSScripts(); i++ ) {
        Scriptable jsR = Context.toObject( jsScripts[ i ].getScript(), data.scope );
        data.scope.put( jsScripts[ i ].getScriptName(), data.scope, jsR );
      }

View on GitHub (pinned to f3058517a1)