{"record":{"id":"827d852218507432","repo":"pentaho/pentaho-kettle","slug":"iae-getmessage","errorCode":null,"errorMessage":"iae.getMessage()","messagePattern":"iae\\.getMessage\\(\\)","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java","lineNumber":190,"sourceCode":"      data.cx = ContextFactory.getGlobal().enterContext();\n\n      try {\n        String optimizationLevelAsString = environmentSubstitute( meta.getOptimizationLevel() );\n        if ( !Utils.isEmpty( Const.trim( optimizationLevelAsString ) ) ) {\n          data.cx.setOptimizationLevel( Integer.parseInt( optimizationLevelAsString.trim() ) );\n          logBasic( BaseMessages.getString( PKG, \"ScriptValuesMod.Optimization.Level\", environmentSubstitute( meta\n            .getOptimizationLevel() ) ) );\n        } else {\n          data.cx.setOptimizationLevel( Integer.parseInt( ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT ) );\n          logBasic( BaseMessages.getString(\n            PKG, \"ScriptValuesMod.Optimization.UsingDefault\", ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT ) );\n        }\n      } catch ( NumberFormatException nfe ) {\n        throw new KettleStepException( BaseMessages.getString(\n          PKG, \"ScriptValuesMetaMod.Exception.NumberFormatException\", environmentSubstitute( meta\n            .getOptimizationLevel() ) ) );\n      } catch ( IllegalArgumentException iae ) {\n        throw new KettleException( iae.getMessage() );\n      }\n\n      data.scope = data.cx.initStandardObjects( null, false );\n\n      bFirstRun = true;\n\n      Scriptable jsvalue = Context.toObject( this, data.scope );\n      data.scope.put( \"_step_\", data.scope, jsvalue );\n\n      // Adding the existing Scripts to the Context\n      for ( int i = 0; i < meta.getNumberOfJSScripts(); i++ ) {\n        Scriptable jsR = Context.toObject( jsScripts[ i ].getScript(), data.scope );\n        data.scope.put( jsScripts[ i ].getScriptName(), data.scope, jsR );\n      }\n\n      // Adding the Name of the Transformation to the Context\n      data.scope.put( \"_TransformationName_\", data.scope, getTransMeta().getName() );\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java#L172-L208","documentation":"Immediately after the NumberFormatException handler, addValues() catches IllegalArgumentException from the Rhino Context initialization (setOptimizationLevel / factory setup) and rethrows a KettleException whose message is simply iae.getMessage(). This surfaces an underlying Rhino IllegalArgumentException directly to the step log, usually meaning the optimization level integer is outside Rhino's supported range or the context factory rejected the configuration.","triggerScenarios":"Context.enter()/setOptimizationLevel(Integer.parseInt(...)) receives a syntactically valid integer that is semantically invalid for Rhino (e.g. optimization level outside the allowed range for the bundled Rhino version), or Context factory rejects the requested setting inside addValues().","commonSituations":"User set optimization level 9 or higher while the embedded Rhino build only supports -1..0 (or vice versa after a Pentaho/Rhino upgrade changed supported levels); passing an extreme negative number other than -1; migrating a transformation between Pentaho versions where the default Rhino context limits differ.","solutions":["Read the raw message in the log — it is the underlying Rhino IllegalArgumentException text — and correct the optimization level accordingly.","Set the Optimization level to a safe value supported by the bundled Rhino (commonly -1 for interpreted mode).","If this appeared after a Pentaho upgrade, check the Rhino version bundled with your Pentaho release for supported optimization levels and adjust the step config.","Avoid exotic values; stick to documented levels (-1, 0, or the documented maximum)."],"exampleFix":"// before\n<optimizationLevel>10</optimizationLevel>  <!-- outside supported Rhino range -->\n// after\n<optimizationLevel>-1</optimizationLevel>  <!-- interpreted mode, universally supported -->","handlingStrategy":"try-catch","validationCode":"// Java, check the optimization level is within the supported Rhino range before running\nint lvl = Integer.parseInt(environmentSubstitute(meta.getOptimizationLevel()).trim());\nif (lvl != -1 && (lvl < 0 || lvl > 9))\n  throw new IllegalArgumentException(\"Optimization level \" + lvl + \" not supported by bundled Rhino\");","typeGuard":null,"tryCatchPattern":"try {\n  transformation.execute(params);\n} catch (KettleException e) {\n  // message is raw iae.getMessage() from Rhino — log it fully\n  log.error(\"Rhino rejected script context config: \" + e.getMessage(), e);\n  // reset optimization level to -1 (interpreted) and retry once\n}","preventionTips":["Use only documented optimization levels (-1 for interpreted, 0/9 per your Rhino version).","After Pentaho upgrades, re-check Rhino-dependent settings in script steps.","Never hand-set extreme optimization values copied from other projects.","Log the full exception chain so the raw Rhino message is visible."],"tags":["kettle","pentaho","rhino","illegal-argument","optimization-level"],"backgroundTag":"value-out-of-range","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}