pentaho/pentaho-kettle · error · KettleValueException
Script.Log.CouldNotAddDefaultConstants
Script.Log.CouldNotAddDefaultConstants
Error message
Script.Log.CouldNotAddDefaultConstants
What it means
Thrown in Script.addValues when adding the default constants to the JavaScript scope fails. The step puts well-known constants (e.g. SKIP_TRANSFORMATION, ERROR_TRANSFORMATION, CONTINUE_TRANSFORMATION) into the Scriptable scope; any Exception raised while doing so is wrapped in a KettleValueException with this message. It indicates scope/context initialization failed, usually due to an underlying Rhino/JS engine problem.
Solutions
- Restart the transformation/JVM to get a fresh scripting context and scope.
- Check the JS engine version bundled with your Pentaho/Kettle distribution and align with the supported version.
- Inspect the wrapped cause (ex) for the underlying scripting-engine error and fix accordingly.
- Verify no custom plugin or jar is replacing/conflicting with the bundled Rhino classes.
Example fix
// before: engine scope shared across runs becomes unusable after an error // after: ensure a fresh scope per run / restart transformation after a script error // (operational fix — no code change available in user space)
Defensive patterns
Strategy: retry
Try / catch
try {
step.processRow();
} catch (KettleValueException e) {
if (e.getMessage().contains("CouldNotAddDefaultConstants")) {
logError("JS scope broken; restarting transformation", e);
// restart transformation / new scripting context, then retry
} else { throw e; }
} Prevention
- Restart the transformation after any scripting error instead of reusing a broken scope.
- Use the Rhino/JS engine version bundled and supported by your Pentaho distribution.
- Avoid plugins that replace scripting-engine jars in lib/.
- Keep one script context per transformation run.
When it happens
Trigger: addValues (called from processRow) executing data.scope.put("_TRANSFORMATION_...") for the default constants and the underlying scope.put throwing any Exception (caught as ex).
Common situations: Rhino/native JS engine version incompatibilities where the shared scope is sealed or in an unexpected state; the context/scope was already closed from a previous failed row; custom plugins altering the scope.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Script.Log.CouldNotAttachAdditionalScripts
- The function call getOcuranceString is not valid
- The function call loadFileContentrequires 1 ou 2 arguments.
- The function call removeCRLF is not valid
- Could not convert the given String :
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/4b8c9832fd66b6d4.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java:247
// ScriptValuesAddedFunctions.class, ScriptableObject.DONTENUM);
// } catch (Exception ex) {
// // System.out.println(ex.toString());
// throw new KettleValueException(BaseMessages.getString(PKG, "Script.Log.CouldNotAddDefaultFunctions"), ex);
// }
// ;
// Adding some Constants to the JavaScript
try {
data.scope.put( "SKIP_TRANSFORMATION", Integer.valueOf( SKIP_TRANSFORMATION ) );
data.scope.put( "ABORT_TRANSFORMATION", Integer.valueOf( ABORT_TRANSFORMATION ) );
data.scope.put( "ERROR_TRANSFORMATION", Integer.valueOf( ERROR_TRANSFORMATION ) );
data.scope.put( "CONTINUE_TRANSFORMATION", Integer.valueOf( CONTINUE_TRANSFORMATION ) );
} catch ( Exception ex ) {
// System.out.println("Exception Adding the Constants " +
// ex.toString());
throw new KettleValueException(
BaseMessages.getString( PKG, "Script.Log.CouldNotAddDefaultConstants" ), ex );
}
try {
// Checking for StartScript
if ( strStartScript != null && strStartScript.length() > 0 ) {
CompiledScript startScript = ( (Compilable) data.cx ).compile( strStartScript );
startScript.eval( 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 " +View on GitHub (pinned to f3058517a1)