{"record":{"id":"71fe0bbb44b929cd","repo":"pentaho/pentaho-kettle","slug":"ifnull-log-selectfieldsempty","errorCode":null,"errorMessage":"IfNull.Log.SelectFieldsEmpty","messagePattern":"IfNull\\.Log\\.SelectFieldsEmpty","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/ifnull/IfNull.java","lineNumber":99,"sourceCode":"          data.fieldnrs = new int[fieldsLength];\n          data.defaultValues = new String[fieldsLength];\n          data.defaultMasks = new String[fieldsLength];\n          data.setEmptyString = new boolean[fieldsLength];\n\n          for ( int i = 0; i < meta.getFields().length; i++ ) {\n            data.fieldnrs[i] = data.outputRowMeta.indexOfValue( meta.getFields()[i].getFieldName() );\n            if ( data.fieldnrs[i] < 0 ) {\n              logError( BaseMessages.getString( PKG, \"IfNull.Log.CanNotFindField\", meta.getFields()[i]\n                  .getFieldName() ) );\n              throw new KettleException( BaseMessages.getString( PKG, \"IfNull.Log.CanNotFindField\", meta.getFields()[i]\n                  .getFieldName() ) );\n            }\n            data.defaultValues[i] = environmentSubstitute( meta.getFields()[i].getReplaceValue() );\n            data.defaultMasks[i] = environmentSubstitute( meta.getFields()[i].getReplaceMask() );\n            data.setEmptyString[i] = meta.getFields()[i].isSetEmptyString();\n          }\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"IfNull.Log.SelectFieldsEmpty\" ) );\n        }\n      } else if ( meta.isSelectValuesType() ) {\n        // Consider only select value types\n        if ( meta.getValueTypes() != null && meta.getValueTypes().length > 0 ) {\n          // return the real default values\n          int typeLength = meta.getValueTypes().length;\n          data.defaultValues = new String[typeLength];\n          data.defaultMasks = new String[typeLength];\n          data.setEmptyString = new boolean[typeLength];\n\n          // return all type codes\n          HashSet<String> AlllistTypes = new HashSet<String>();\n          for ( int i = 0; i < ValueMetaInterface.typeCodes.length; i++ ) {\n            AlllistTypes.add( ValueMetaInterface.typeCodes[i] );\n          }\n\n          for ( int i = 0; i < meta.getValueTypes().length; i++ ) {\n            if ( !AlllistTypes.contains( meta.getValueTypes()[i].getTypeName() ) ) {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/ifnull/IfNull.java#L81-L117","documentation":"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.","triggerScenarios":"processRow with meta.isSelectFieldsType() true and meta.getFields() == null || meta.getFields().length == 0.","commonSituations":"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.","solutions":["Open the If Null step and add at least one field with its replace value","If building the step in code, call meta.setFields(...) before execution","Re-validate the transformation with the check feature to catch the empty configuration early"],"exampleFix":"// before\nIfNullMeta meta = new IfNullMeta();\nmeta.setSelectFieldsType(true);\ntrans.addStep(...); // no fields set\n// after\nIfNullMeta meta = new IfNullMeta();\nmeta.setSelectFieldsType(true);\nmeta.setFields(new IfNullField[] { new IfNullField(\"status\", \"N/A\", null, false) });","handlingStrategy":"validation","validationCode":"IfNullField[] fs = meta.getFields(); if (fs == null || fs.length == 0) throw new IllegalStateException(\"No fields selected\");","typeGuard":"boolean hasFields(IfNullMeta m) { return m.getFields() != null && m.getFields().length > 0; }","tryCatchPattern":"try { trans.execute(null); } catch (KettleException e) { if (e.getMessage().contains(\"SelectFieldsEmpty\")) { fixStepConfig(); } else { throw e; } }","preventionTips":["Run CheckResults on the step before executing","Never save a transformation with the If Null fields list empty","Validate step configs after repository/XML loads"],"tags":["kettle","transformation","empty-config"],"backgroundTag":"empty-required-field","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"}