pentaho/pentaho-kettle · error · KettleException

IfNull.Log.SelectFieldsEmpty

Error message

IfNull.Log.SelectFieldsEmpty

What it means

When the If Null step is configured with 'select fields' mode, processRow() requires at least one field to be selected. If meta.getFields() is null or empty, it throws this KettleException because there is nothing to apply null-replacement to.

Solutions

  1. Open the If Null step and add at least one field with its replace value
  2. If building the step in code, call meta.setFields(...) before execution
  3. Re-validate the transformation with the check feature to catch the empty configuration early

Example fix

// before
IfNullMeta meta = new IfNullMeta();
meta.setSelectFieldsType(true);
trans.addStep(...); // no fields set
// after
IfNullMeta meta = new IfNullMeta();
meta.setSelectFieldsType(true);
meta.setFields(new IfNullField[] { new IfNullField("status", "N/A", null, false) });
Defensive patterns

Strategy: validation

Validate before calling

IfNullField[] fs = meta.getFields(); if (fs == null || fs.length == 0) throw new IllegalStateException("No fields selected");

Type guard

boolean hasFields(IfNullMeta m) { return m.getFields() != null && m.getFields().length > 0; }

Try / catch

try { trans.execute(null); } catch (KettleException e) { if (e.getMessage().contains("SelectFieldsEmpty")) { fixStepConfig(); } else { throw e; } }

Prevention

When it happens

Trigger: processRow with meta.isSelectFieldsType() true and meta.getFields() == null || meta.getFields().length == 0.

Common situations: Transformation saved with no fields chosen in the If Null dialog; fields list lost during repository/XML round-trip; step added programmatically without populating fields.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/ifnull/IfNull.java:99

          data.fieldnrs = new int[fieldsLength];
          data.defaultValues = new String[fieldsLength];
          data.defaultMasks = new String[fieldsLength];
          data.setEmptyString = new boolean[fieldsLength];

          for ( int i = 0; i < meta.getFields().length; i++ ) {
            data.fieldnrs[i] = data.outputRowMeta.indexOfValue( meta.getFields()[i].getFieldName() );
            if ( data.fieldnrs[i] < 0 ) {
              logError( BaseMessages.getString( PKG, "IfNull.Log.CanNotFindField", meta.getFields()[i]
                  .getFieldName() ) );
              throw new KettleException( BaseMessages.getString( PKG, "IfNull.Log.CanNotFindField", meta.getFields()[i]
                  .getFieldName() ) );
            }
            data.defaultValues[i] = environmentSubstitute( meta.getFields()[i].getReplaceValue() );
            data.defaultMasks[i] = environmentSubstitute( meta.getFields()[i].getReplaceMask() );
            data.setEmptyString[i] = meta.getFields()[i].isSetEmptyString();
          }
        } else {
          throw new KettleException( BaseMessages.getString( PKG, "IfNull.Log.SelectFieldsEmpty" ) );
        }
      } else if ( meta.isSelectValuesType() ) {
        // Consider only select value types
        if ( meta.getValueTypes() != null && meta.getValueTypes().length > 0 ) {
          // return the real default values
          int typeLength = meta.getValueTypes().length;
          data.defaultValues = new String[typeLength];
          data.defaultMasks = new String[typeLength];
          data.setEmptyString = new boolean[typeLength];

          // return all type codes
          HashSet<String> AlllistTypes = new HashSet<String>();
          for ( int i = 0; i < ValueMetaInterface.typeCodes.length; i++ ) {
            AlllistTypes.add( ValueMetaInterface.typeCodes[i] );
          }

          for ( int i = 0; i < meta.getValueTypes().length; i++ ) {
            if ( !AlllistTypes.contains( meta.getValueTypes()[i].getTypeName() ) ) {

View on GitHub (pinned to f3058517a1)