{"record":{"id":"95997bc1eed6a8f4","repo":"pentaho/pentaho-kettle","slug":"scriptvaluesdialogmod-exception-couldnotgetfields","errorCode":null,"errorMessage":"ScriptValuesDialogMod.Exception.CouldNotGetFields","messagePattern":"ScriptValuesDialogMod\\.Exception\\.CouldNotGetFields","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/trans/steps/scriptvalues_mod/ScriptValuesModDialog.java","lineNumber":1273,"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(\n          PKG, \"ScriptValuesDialogMod.Exception.CouldNotGetFields\" ) );\n      }\n    } catch ( Exception e ) {\n      new ErrorDialog(\n        shell, BaseMessages.getString( PKG, \"ScriptValuesDialogMod.TestFailed.DialogTitle\" ), BaseMessages\n          .getString( PKG, \"ScriptValuesDialogMod.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;","sourceCodeStart":1255,"sourceCodeEnd":1291,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/trans/steps/scriptvalues_mod/ScriptValuesModDialog.java#L1255-L1291","documentation":"In ScriptValuesModDialog's test/preview path, when the step cannot produce input field metadata (getFields fails or returns no usable state) the dialog throws this KettleException keyed to message ScriptValuesDialogMod.Exception.CouldNotGetFields. It means field metadata required to run the 'Test script' feature could not be obtained from the surrounding transformation.","triggerScenarios":"Clicking 'Test script' in the Script Values Mod dialog when the previous step is disconnected/absent or its fields cannot be resolved (prevInfo == null / getFieldInfo failure path where the else branch executes).","commonSituations":"Testing a script in a step that is not yet wired to an upstream step; upstream step returns no rows metadata; hop misconfigured; running dialog against a partially built transformation.","solutions":["Connect the ScriptValues step to a valid upstream step before testing the script","Ensure the previous step can resolve row metadata (run/preview the upstream step first)","Check the hop between steps is enabled and correctly oriented","If fields depend on other steps, verify those steps are configured"],"exampleFix":"// before: testing with no upstream hop\nStepMeta prev = transMeta.findPreviousStep( stepMeta, true ); // returns null -> exception\n// after: guard in dialog logic\nif ( prev != null && transMeta.getPrevStepFields( stepMeta ) != null ) { testScript(); } else { showWarning( \"Connect an input step first\" ); }","handlingStrategy":"validation","validationCode":"// Java: ensure a previous step exists and fields resolve before testing\nStepMeta prev = transMeta.findPreviousStep( stepMeta, true );\nboolean canTest = prev != null && transMeta.getPrevStepFields( stepMeta ) != null;","typeGuard":"boolean hasUpstreamFields = transMeta.findPreviousStep( stepMeta, true ) != null;","tryCatchPattern":"try { testScript(); } catch ( KettleException e ) { new ErrorDialog( shell, \"Test failed\", \"Could not get fields\", e ); }","preventionTips":["Always connect an input hop before using 'Test script'","Preview the upstream step to confirm row metadata resolves","Keep upstream steps fully configured before testing downstream scripts"],"tags":["ui","metadata","scripting","transformation"],"backgroundTag":"empty-result-set","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"}