{"record":{"id":"e2e7117c3f416095","repo":"pentaho/pentaho-kettle","slug":"unable-to-find-field-0-in-the-input-rows","errorCode":null,"errorMessage":"Unable to find field [{0}] in the input rows","messagePattern":"Unable to find field \\[(.+?)\\] in the input rows","errorType":"exception","errorClass":"KettleStepException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/step/utils/RowMetaUtils.java","lineNumber":38,"sourceCode":"import org.pentaho.di.core.row.ValueMetaInterface;\n\npublic class RowMetaUtils {\n\n  public static RowMetaInterface getRowMetaForUpdate( RowMetaInterface prev, String[] keyLookup, String[] keyStream,\n      String[] updateLookup, String[] updateStream ) throws KettleStepException {\n    RowMetaInterface tableFields = new RowMeta();\n\n    // Now change the field names\n    // the key fields\n    if ( keyLookup != null ) {\n      for ( int i = 0; i < keyLookup.length; i++ ) {\n        ValueMetaInterface v = prev.searchValueMeta( keyStream[i] );\n        if ( v != null ) {\n          ValueMetaInterface tableField = v.clone();\n          tableField.setName( keyLookup[i] );\n          tableFields.addValueMeta( tableField );\n        } else {\n          throw new KettleStepException( \"Unable to find field [\" + keyStream[i] + \"] in the input rows\" );\n        }\n      }\n    }\n    // the lookup fields\n    for ( int i = 0; i < updateLookup.length; i++ ) {\n      ValueMetaInterface v = prev.searchValueMeta( updateStream[i] );\n      if ( v != null ) {\n        ValueMetaInterface vk = tableFields.searchValueMeta( updateLookup[i] );\n        if ( vk == null ) { // do not add again when already added as key fields\n          ValueMetaInterface tableField = v.clone();\n          tableField.setName( updateLookup[i] );\n          tableFields.addValueMeta( tableField );\n        }\n      } else {\n        throw new KettleStepException( \"Unable to find field [\" + updateStream[i] + \"] in the input rows\" );\n      }\n    }\n    return tableFields;","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/step/utils/RowMetaUtils.java#L20-L56","documentation":"KettleStepException thrown by RowMetaUtils.getRowMetaForUpdate when a key stream field listed for a database update/lookup operation is not present in the incoming row metadata. It means the mapping between the table key columns (keyLookup) and the stream fields (keyStream) references a field name the input rows don't provide.","triggerScenarios":"getRowMetaForUpdate called during metadata initialization of insert/update/delete steps; prev.searchValueMeta(keyStream[i]) returns null because keyStream[i] names a field absent from the previous step's output rows — typically after renaming/deleting fields upstream.","commonSituations":"Renaming a field in an upstream Select values step without updating the Update/Insert-Update step's key mapping; a source column dropped in a table input step; copied transformation with field references stale after schema change.","solutions":["Open the Update/Insert-Update step and re-map the key fields to existing input fields (Get Fields)","Trace upstream: find where the field was renamed or removed and fix the reference","Use 'Get update fields'/'Get fields' button in the step dialog to refresh mappings after schema changes","Add a Select Values step aliasing the new field name back to the expected name if renaming is intentional"],"exampleFix":"// before: keyStream references deleted field\nkeyStream = [\"old_id\"]; keyLookup = [\"ID\"]  // old_id no longer in rows\n// after: remap to current field\nkeyStream = [\"new_id\"]; keyLookup = [\"ID\"]  // new_id exists in input rows","handlingStrategy":"validation","validationCode":"// Validate key stream fields exist in previous step's row meta before running\nRowMetaInterface prev = transMeta.getPrevStepFields(updateStepName);\nfor (int i = 0; i < keyStream.length; i++) {\n  if (prev.searchValueMeta(keyStream[i]) == null) {\n    throw new IllegalStateException(\"Field not in input rows: \" + keyStream[i]);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  transMeta.prepareExecution(variables);\n} catch (KettleStepException e) {\n  if (e.getMessage().startsWith(\"Unable to find field [\")) {\n    String field = e.getMessage().replaceAll(\".*\\\\[(.*)\\\\].*\", \"$1\");\n    log.error(\"Remap key field in Update step: \" + field);\n  }\n  throw e;\n}","preventionTips":["After any upstream field rename, re-open dependent Update/Delete/Insert-Update steps and refresh mappings","Use the 'Get fields' button in step dialogs instead of typing field names manually","Add a Select Values alias step to preserve legacy field names across refactors","Validate transformations in CI by calling prepareExecution before deployment"],"tags":["row-metadata","field-mapping","database-update"],"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"}