pentaho/pentaho-kettle · error · KettleException

ScriptDialog.Exception.CouldNotGetFields

Error message

ScriptDialog.Exception.CouldNotGetFields

What it means

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.

Solutions

  1. Fix syntax/semantic errors in the script so it can run and produce field values
  2. Ensure the script assigns values to the declared output fields
  3. Verify the selected script language matches the code (e.g. JS vs Python)
  4. Check the details in the 'Test failed' ErrorDialog for the underlying cause

Example fix

// before
var x = ; // syntax error
// after
var x = 1; // valid script that can yield output fields
Defensive patterns

Strategy: try-catch

Validate before calling

// run the script in a dry-run and confirm it yields output field values before opening the dialog

Try / catch

boolean ok = false;
try { ok = testScript(); } catch (Exception e) { new ErrorDialog(shell, title, msg, e); }
if (!ok) { /* fix script so output fields can be derived */ }

Prevention

When it happens

Trigger: 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.

Common situations: JavaScript/Python script with syntax errors, referencing undefined variables, script language mismatched with the pasted code, or script that never assigns output fields.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/c5126b9fb3b5b8c3. Report an issue: GitHub.

Appendix: source

Thrown at ui/src/main/java/org/pentaho/di/ui/trans/steps/script/ScriptDialog.java:1180

              etd.setReadOnly();
              etd.open();
            }
          }

          RowMetaInterface previewRowsMeta = progressDialog.getPreviewRowsMeta( wStepname.getText() );
          List<Object[]> previewRows = progressDialog.getPreviewRows( wStepname.getText() );

          if ( previewRowsMeta != null && previewRows != null && previewRows.size() > 0 ) {
            PreviewRowsDialog prd =
              new PreviewRowsDialog(
                shell, transMeta, SWT.NONE, wStepname.getText(), previewRowsMeta, previewRows, loggingText );
            prd.open();
          }
        }

        return true;
      } else {
        throw new KettleException( BaseMessages.getString( PKG, "ScriptDialog.Exception.CouldNotGetFields" ) );
      }
    } catch ( Exception e ) {
      new ErrorDialog( shell, BaseMessages.getString( PKG, "ScriptDialog.TestFailed.DialogTitle" ), BaseMessages
        .getString( PKG, "ScriptDialog.TestFailed.DialogMessage" ), e );
      return false;
    }

  }

  private boolean test( boolean getvars, boolean popup ) {
    boolean retval = true;
    StyledTextComp wScript = getStyledTextComp();
    String scr = wScript.getText();
    KettleException testException = null;

    Context jscx;
    Scriptable jsscope;
    // Script jsscript;

View on GitHub (pinned to f3058517a1)