{"record":{"id":"c5126b9fb3b5b8c3","repo":"pentaho/pentaho-kettle","slug":"scriptdialog-exception-couldnotgetfields","errorCode":null,"errorMessage":"ScriptDialog.Exception.CouldNotGetFields","messagePattern":"ScriptDialog\\.Exception\\.CouldNotGetFields","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/trans/steps/script/ScriptDialog.java","lineNumber":1180,"sourceCode":"              etd.setReadOnly();\n              etd.open();\n            }\n          }\n\n          RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta( wStepname.getText() );\n          List<Object[]> previewRows = progressDialog.getPreviewRows( wStepname.getText() );\n\n          if ( previewRowsMeta != null && previewRows != null && previewRows.size() > 0 ) {\n            PreviewRowsDialog prd =\n              new PreviewRowsDialog(\n                shell, transMeta, SWT.NONE, wStepname.getText(), previewRowsMeta, previewRows, loggingText );\n            prd.open();\n          }\n        }\n\n        return true;\n      } else {\n        throw new KettleException( BaseMessages.getString( PKG, \"ScriptDialog.Exception.CouldNotGetFields\" ) );\n      }\n    } catch ( Exception e ) {\n      new ErrorDialog( shell, BaseMessages.getString( PKG, \"ScriptDialog.TestFailed.DialogTitle\" ), BaseMessages\n        .getString( PKG, \"ScriptDialog.TestFailed.DialogMessage\" ), e );\n      return false;\n    }\n\n  }\n\n  private boolean test( boolean getvars, boolean popup ) {\n    boolean retval = true;\n    StyledTextComp wScript = getStyledTextComp();\n    String scr = wScript.getText();\n    KettleException testException = null;\n\n    Context jscx;\n    Scriptable jsscope;\n    // Script jsscript;","sourceCodeStart":1162,"sourceCodeEnd":1198,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/trans/steps/script/ScriptDialog.java#L1162-L1198","documentation":"Thrown in ScriptDialog when testing/modifying the script: the engine could not derive output fields from the script (getFieldResult returned no success), so the dialog reports it could not get fields. The exception is then shown via an ErrorDialog as a test failure.","triggerScenarios":"Clicking 'Test script' / apply in the Script dialog where the script cannot be executed far enough to produce field metadata — e.g. script syntax errors, wrong script type selection, or a script that computes no output values.","commonSituations":"JavaScript/Python script with syntax errors, referencing undefined variables, script language mismatched with the pasted code, or script that never assigns output fields.","solutions":["Fix syntax/semantic errors in the script so it can run and produce field values","Ensure the script assigns values to the declared output fields","Verify the selected script language matches the code (e.g. JS vs Python)","Check the details in the 'Test failed' ErrorDialog for the underlying cause"],"exampleFix":"// before\nvar x = ; // syntax error\n// after\nvar x = 1; // valid script that can yield output fields","handlingStrategy":"try-catch","validationCode":"// run the script in a dry-run and confirm it yields output field values before opening the dialog","typeGuard":null,"tryCatchPattern":"boolean ok = false;\ntry { ok = testScript(); } catch (Exception e) { new ErrorDialog(shell, title, msg, e); }\nif (!ok) { /* fix script so output fields can be derived */ }","preventionTips":["Validate script syntax in the editor before testing","Ensure the script assigns its output fields","Match script language setting to the actual code"],"tags":["pentaho-kettle","swt-dialog","scripting","field-metadata"],"backgroundTag":"invalid-argument-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"}