{"record":{"id":"1ca61f59c435013a","repo":"pentaho/pentaho-kettle","slug":"scriptvaluesmod-log-errorprocessingstartscript","errorCode":null,"errorMessage":"ScriptValuesMod.Log.ErrorProcessingStartScript","messagePattern":"ScriptValuesMod\\.Log\\.ErrorProcessingStartScript","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java","lineNumber":307,"sourceCode":"            PKG, \"ScriptValuesMod.Log.CouldNotAddDefaultConstants\" ), ex );\n        }\n\n        try {\n          // Checking for StartScript\n          if ( strStartScript != null && strStartScript.length() > 0 ) {\n            Script startScript = data.cx.compileString( strStartScript, \"trans_Start\", 1, null );\n            startScript.exec( data.cx, data.scope );\n            if ( log.isDetailed() ) {\n              logDetailed( ( \"Start Script found!\" ) );\n            }\n          } else {\n            if ( log.isDetailed() ) {\n              logDetailed( ( \"No starting Script found!\" ) );\n            }\n          }\n        } catch ( Exception es ) {\n          // System.out.println(\"Exception processing StartScript \" + es.toString());\n          throw new KettleValueException( BaseMessages.getString(\n            PKG, \"ScriptValuesMod.Log.ErrorProcessingStartScript\" ), es );\n\n        }\n        // Now Compile our Script\n        data.script = data.cx.compileString( strTransformScript, \"script\", 1, null );\n      } catch ( Exception e ) {\n        throw new KettleValueException( BaseMessages.getString(\n          PKG, \"ScriptValuesMod.Log.CouldNotCompileJavascript\" ), e );\n      }\n    }\n\n    // Filling the defined TranVars with the Values from the Row\n    //\n    Object[] outputRow = RowDataUtil.resizeArray( row, data.outputRowMeta.size() );\n\n    // Keep an index...\n    int outputIndex = rowMeta.size();\n","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java#L289-L325","documentation":"Thrown when the optional Start Script configured in the Modified Java Script Value step fails during execution. addValues() runs strStartScript through the Rhino engine after the constants are registered; any Exception thrown by that startup script is wrapped in a KettleValueException with this message. The cause carries the actual script error.","triggerScenarios":"The user entered a non-empty Start Script (strStartScript) in the step dialog and executing it with data.cx throws (syntax error, undefined variable, invalid API call) during addValues() called from processRow.","commonSituations":"Copy-pasted start script with typos, referencing fields/functions not yet defined, using Rhino-unsupported ES6 syntax, or calling transformation APIs with wrong arguments in the Start Script tab.","solutions":["Open the Start Script tab and fix the script error shown in the chained 'Caused by' stack trace","Test the script logic in a minimal standalone script to reproduce the exception","Remove or temporarily empty the Start Script to confirm it is the failing part","Replace unsupported modern JS syntax with Rhino-compatible (ES5) code","Move initialization logic that doesn't need to run first into the main transform script"],"exampleFix":"// before: start script using unsupported syntax\nvar cfg = { fields: [\"a\",\"b\"] }; // arrow fns, let/const, etc. may fail on old Rhino\n// after: ES5-compatible start script\nvar cfg = new Object();\ncfg.fields = [ \"a\", \"b\" ];","handlingStrategy":"validation","validationCode":"// Validate the start script parses before configuring the step (ES5-only)\nfunction validateStartScript(src) {\n  try { new Function(src); return true; } catch (e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  processRow();\n} catch ( KettleValueException e ) {\n  if ( e.getMessage().contains( \"ErrorProcessingStartScript\" ) ) {\n    logError( \"Start script failed: \" + e.getCause(), e );\n  }\n  throw e;\n}","preventionTips":["Keep the Start Script minimal (variable declarations only)","Stick to ES5 syntax compatible with the bundled Rhino","Test the start script in a standalone JS engine before pasting it into the step"],"tags":["javascript","rhino","script-error","start-script"],"backgroundTag":"invalid-config-value","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"}