{"record":{"id":"a5bf4e4284deb8e5","repo":"pentaho/pentaho-kettle","slug":"script-log-couldnotcompilejavascript","errorCode":"Script.Log.CouldNotCompileJavascript","errorMessage":"Script.Log.CouldNotCompileJavascript","messagePattern":"Script\\.Log\\.CouldNotCompileJavascript","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java","lineNumber":279,"sourceCode":"              logDetailed( ( \"No starting Script found!\" ) );\n            }\n          }\n        } catch ( Exception es ) {\n          // System.out.println(\"Exception processing StartScript \" +\n          // es.toString());\n          throw new KettleValueException(\n            BaseMessages.getString( PKG, \"Script.Log.ErrorProcessingStartScript\" ), es );\n\n        }\n        // Now Compile our Script\n        // alternatively you could also support non compilable JSR223\n        // languages, see how we were doing before:\n        // http://github.com/rvalyi/jripple/blob/e6190fd89014a49b0faffae68c75762be124d899/\n        // src/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java\n\n        data.script = ( (Compilable) data.cx ).compile( strTransformScript );\n      } catch ( Exception e ) {\n        throw new KettleValueException( BaseMessages.getString( PKG, \"Script.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\n    try {\n      try {\n        data.scope.put( \"row\", row );\n\n        for ( int i = 0; i < data.fields_used.length; i++ ) {\n          ValueMetaInterface valueMeta = rowMeta.getValueMeta( data.fields_used[ i ] );\n          Object valueData = row[ data.fields_used[ i ] ];\n","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java#L261-L297","documentation":"Thrown in Script.addValues when compilation of the main transform script fails. The step casts its JS engine context to javax.script.Compilable and calls compile(strTransformScript); any Exception (most commonly a script syntax error) is wrapped in a KettleValueException with this message. The transformation cannot proceed because the script never compiles.","triggerScenarios":"addValues (called from processRow): ((Compilable) data.cx).compile(strTransformScript) throws, typically a ScriptSyntaxError from malformed JavaScript in the transform script tab; it fires on the first processed row (script compiled lazily on first use).","commonSituations":"Typos/syntax errors in the transform script; using Rhino-only syntax not accepted by the JSR-223 engine; non-ASCII characters or smart quotes pasted from editors; scripts referencing Pentaho-specific globals are fine, but stray HTML/XML pasted into the editor is not.","solutions":["Use the step's 'Test script' button to locate and fix the JavaScript syntax error.","Check the wrapped cause for the exact line/column of the parse error.","Remove pasted artifacts (smart quotes, HTML) and retype the offending line.","Confirm the script targets the JSR-223 compliant engine shipped with your Pentaho version."],"exampleFix":"// before\nvar total = price * ;\n// after\nvar total = price * quantity;","handlingStrategy":"validation","validationCode":"// pre-compile the script to catch syntax errors before the run\ntry {\n  new javax.script.ScriptEngineManager().getEngineByName(\"ECMAScript\").eval(strTransformScript);\n} catch (ScriptException se) {\n  throw new IllegalStateException(\"Transform script syntax error: \" + se.getMessage());\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.processRow();\n} catch (KettleValueException e) {\n  if (e.getMessage().contains(\"CouldNotCompileJavascript\")) {\n    logError(\"Fix transform script syntax: \" + e.getCause().getMessage());\n  } else { throw e; }\n}","preventionTips":["Always use the Test script button before saving/running.","Avoid pasting from rich-text editors (smart quotes, invisible characters).","Write engine-portable JavaScript (no Rhino-only extensions when using JSR-223).","Lint the script in an external editor for early syntax detection."],"tags":["kettle","javascript","syntax-error","compilation"],"backgroundTag":"invalid-regex-pattern","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"}