{"record":{"id":"dfd0a564ada51c56","repo":"pentaho/pentaho-kettle","slug":"flattenermeta-exception-unabletolocatefieldininputfields","errorCode":"FlattenerMeta.Exception.UnableToLocateFieldInInputFields","errorMessage":"FlattenerMeta.Exception.UnableToLocateFieldInInputFields","messagePattern":"FlattenerMeta\\.Exception\\.UnableToLocateFieldInInputFields","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/flattener/FlattenerMeta.java","lineNumber":108,"sourceCode":"    return retval;\n  }\n\n  public void setDefault() {\n    int nrfields = 0;\n\n    allocate( nrfields );\n  }\n\n  @Override\n  public void getFields( Bowl bowl, RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep,\n    VariableSpace space, Repository repository, IMetaStore metaStore ) throws KettleStepException {\n\n    // Remove the key value (there will be different entries for each output row)\n    //\n    if ( fieldName != null && fieldName.length() > 0 ) {\n      int idx = row.indexOfValue( fieldName );\n      if ( idx < 0 ) {\n        throw new KettleStepException( BaseMessages.getString(\n          PKG, \"FlattenerMeta.Exception.UnableToLocateFieldInInputFields\", fieldName ) );\n      }\n\n      ValueMetaInterface v = row.getValueMeta( idx );\n      row.removeValueMeta( idx );\n\n      for ( int i = 0; i < targetField.length; i++ ) {\n        ValueMetaInterface value = v.clone();\n        value.setName( targetField[i] );\n        value.setOrigin( name );\n\n        row.addValueMeta( value );\n      }\n    } else {\n      throw new KettleStepException( BaseMessages.getString( PKG, \"FlattenerMeta.Exception.FlattenFieldRequired\" ) );\n    }\n  }\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/flattener/FlattenerMeta.java#L90-L126","documentation":"FlattenerMeta.getFields validates row layout at transformation initialization and throws KettleStepException with this localized message when the configured 'field to flatten' (fieldName) is not present in the incoming row's fields. The flattener needs that key column to group rows.","triggerScenarios":"Running/previewing a Flattener step whose fieldName does not match any value name in the incoming RowMeta — indexOfValue returns -1.","commonSituations":"Renamed or removed the source field upstream; connected the wrong stream into the Flattener; typo or case mismatch in the field name after editing the transformation.","solutions":["Open the Flattener step and re-select 'The field to flatten' from the actual incoming fields","Verify the upstream step still emits that field (preview the input stream)","Fix field-name casing/typos — matching is exact","Re-run getFields/preview to confirm the row layout now contains the field"],"exampleFix":"// before\nString fieldName = \"cust_name\"; // upstream renamed it\n// after\nString fieldName = \"customer_name\"; // match the actual upstream field","handlingStrategy":"validation","validationCode":"// before running: verify the flatten field exists in the incoming stream\nString[] fields = transMeta.getPrevStepFields( stepMeta ).getFieldNames();\nboolean found = java.util.Arrays.asList( fields ).contains( \"fieldToFlatten\" );\nif ( !found ) throw new IllegalStateException( \"Field 'fieldToFlatten' not in input stream\" );","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute( null );\n} catch ( KettleStepException e ) {\n  if ( String.valueOf( e.getMessage() ).contains( \"UnableToLocateFieldInInputFields\" ) ||\n       String.valueOf( e.getMessage() ).contains( \"field to flatten\" ) ) {\n    // re-check upstream field names and step config\n  }\n}","preventionTips":["Re-select the flatten field after any upstream rename","Preview the input stream to confirm field names","Keep field naming consistent across steps","Use the step's 'Get fields' button instead of typing names"],"tags":["pdi","kettle","row-layout","flattener"],"backgroundTag":"resource-not-found","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"}