pentaho/pentaho-kettle · error · KettleStepException

throw new KettleStepException( e );

Error message

throw new KettleStepException( e );

What it means

KettleStepException thrown in FormulaMeta.getFields() when ValueMetaFactory.createValueMeta() fails while building the step's output row metadata (e.g. unknown or invalid value type code). It wraps the underlying exception from metadata construction at design/initialization time.

Solutions

  1. Inspect the cause to find which field's value type is invalid.
  2. Reopen the Formula step dialog and re-select the output Type for the offending formula row.
  3. Open/save the transformation with a Kettle version matching the one that created it.
  4. If hand-editing XML, use valid ValueMetaInterface type codes (e.g. 2=Number, 5=String).

Example fix

// before (ktr xml)
<value_type>999</value_type>
// after
<value_type>5</value_type>
Defensive patterns

Strategy: try-catch

Validate before calling

int knownTypes = ValueMetaInterface.TYPE_STRING | ValueMetaInterface.TYPE_NUMBER | /* ...valid mask... */ 0;
// ensure fn.getValueType() is a supported ValueMetaInterface.TYPE_* before calling getFields()

Try / catch

try { meta.getFields(row, name, info, target, repository, imeta); } catch (KettleStepException e) { log.error("Invalid value type in Formula meta: " + e.getCause(), e); throw e; }

Prevention

When it happens

Trigger: Calling getFields() on a FormulaMeta whose FormulaMetaFunction entries carry an invalid valueType (e.g. corrupted meta, unsupported type constant) so createValueMeta throws.

Common situations: Hand-edited .ktr XML with an out-of-range type attribute; transformation serialized by a newer Kettle version with a type the current one doesn't know; plugin version mismatch.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/formula/FormulaMeta.java:159

  }

  @Override
  public void getFields( Bowl bowl, RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,
    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {
    for ( int i = 0; i < formula.length; i++ ) {
      FormulaMetaFunction fn = formula[i];
      if ( Utils.isEmpty( fn.getReplaceField() ) ) {
        // Not replacing a field.
        if ( !Utils.isEmpty( fn.getFieldName() ) ) {
          // It's a new field!

          try {
            ValueMetaInterface v = ValueMetaFactory.createValueMeta( fn.getFieldName(), fn.getValueType() );
            v.setLength( fn.getValueLength(), fn.getValuePrecision() );
            v.setOrigin( name );
            row.addValueMeta( v );
          } catch ( Exception e ) {
            throw new KettleStepException( e );
          }
        }
      } else {
        // Replacing a field
        int index = row.indexOfValue( fn.getReplaceField() );
        if ( index < 0 ) {
          throw new KettleStepException( "Unknown field specified to replace with a formula result: ["
            + fn.getReplaceField() + "]" );
        }
        // Change the data type etc.
        //
        ValueMetaInterface v = row.getValueMeta( index ).clone();
        v.setLength( fn.getValueLength(), fn.getValuePrecision() );
        v.setOrigin( name );
        row.setValueMeta( index, v ); // replace it
      }
    }
  }

View on GitHub (pinned to f3058517a1)