pentaho/pentaho-kettle · error · KettleValueException

No name was specified for result value #

Error message

No name was specified for result value #{i}

What it means

Kettle's Script step throws KettleValueException when generating an output value from a JavaScript result but no field name was configured for that result value index. The step iterates the configured result fields (meta.getFieldName()[i]); if the name slot is empty/null it cannot place the converted value into the output row, so it fails fast.

Solutions

  1. Open the Script step dialog and set a non-empty 'Field name' for every entry in the fields grid
  2. Edit the .ktr XML and ensure each <field> under the Script step has a populated <field_name> element
  3. Verify programmatically: iterate meta.getFieldName() and reject null/blank names before execution
  4. If the field is not needed, remove the whole field entry rather than leaving the name blank

Example fix

// before (ktr metadata)
<field>
  <field_name></field_name>
  <field_type>String</field_type>
</field>
// after
<field>
  <field_name>resultValue</field_name>
  <field_type>String</field_type>
</field>
Defensive patterns

Strategy: validation

Validate before calling

for (int i = 0; i < meta.getFieldName().length; i++) {
  if (meta.getFieldName()[i] == null || meta.getFieldName()[i].trim().isEmpty()) {
    throw new IllegalArgumentException("Result value #" + (i + 1) + " has no field name");
  }
}

Type guard

boolean hasFieldName(ScriptMeta meta, int i) {
  return i < meta.getFieldName().length
    && meta.getFieldName()[i] != null
    && !meta.getFieldName()[i].trim().isEmpty();
}

Try / catch

try {
  Object v = script.getValueFromJScript(i);
} catch (KettleValueException e) {
  logError("Result field name missing or JS error: " + e.getMessage());
  throw e;
}

Prevention

When it happens

Trigger: Calling getValueFromJScript(i) for a result index i whose configured field name in the Script step metadata (meta.getFieldName()[i]) is null or empty. This happens when the transform's XML/dialog configuration declares a value of a given type but leaves the 'Field name' blank.

Common situations: Hand-edited or programmatically generated transformation ktr XML missing the <field_name> element; a step copied between transforms where the rename was lost; upgrading/migrating transforms where metadata mapping changed and name fields ended up empty.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java:404

      throw new KettleValueException( BaseMessages.getString( PKG, "Script.Log.JavascriptError" ), e );
    }
    return bRC;
  }

  public Object getValueFromJScript( Object result, int i ) throws KettleValueException {
    String fieldName = meta.getFieldname()[ i ];
    if ( !Utils.isEmpty( fieldName ) ) {
      // res.setName(meta.getRename()[i]);
      // res.setType(meta.getType()[i]);

      try {
        return ( result == null ) ? null
          : JavaScriptUtils.convertFromJs( result, meta.getType()[ i ], fieldName );
      } catch ( Exception e ) {
        throw new KettleValueException( BaseMessages.getString( PKG, "Script.Log.JavascriptError" ), e );
      }
    } else {
      throw new KettleValueException( "No name was specified for result value #" + ( i + 1 ) );
    }
  }

  public RowMetaInterface getOutputRowMeta() {
    return data.outputRowMeta;
  }

  public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException {

    meta = (ScriptMeta) smi;
    data = (ScriptData) sdi;

    Object[] r = getRow(); // Get row from input rowset & set row busy!
    if ( r == null ) {
      // Modification for Additional End Function
      try {
        if ( data.cx != null ) {
          // Checking for EndScript

View on GitHub (pinned to f3058517a1)