{"record":{"id":"8e3fe9d218807dde","repo":"pentaho/pentaho-kettle","slug":"fuzzymatch-exception-couldnotfindmainfield","errorCode":null,"errorMessage":"FuzzyMatch.Exception.CouldnotFindMainField","messagePattern":"FuzzyMatch\\.Exception\\.CouldnotFindMainField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/fuzzymatch/FuzzyMatch.java","lineNumber":177,"sourceCode":"    }\n\n    return true;\n  }\n\n  private Object[] lookupValues( RowMetaInterface rowMeta, Object[] row ) throws KettleException {\n    if ( first ) {\n      first = false;\n\n      data.outputRowMeta = getInputRowMeta().clone();\n      meta.getFields(\n        getTransMeta().getBowl(), data.outputRowMeta, getStepname(), new RowMetaInterface[] { data.infoMeta }, null,\n        this, repository, metaStore );\n\n      // Check lookup field\n      data.indexOfMainField = getInputRowMeta().indexOfValue( environmentSubstitute( meta.getMainStreamField() ) );\n      if ( data.indexOfMainField < 0 ) {\n        // The field is unreachable !\n        throw new KettleException( BaseMessages.getString( PKG, \"FuzzyMatch.Exception.CouldnotFindMainField\", meta\n          .getMainStreamField() ) );\n      }\n    }\n    Object[] add = null;\n    if ( row[ data.indexOfMainField ] == null ) {\n      add = buildEmptyRow();\n    } else {\n      try {\n        add = getFromCache( row );\n      } catch ( Exception e ) {\n        throw new KettleStepException( e );\n      }\n    }\n    return RowDataUtil.addRowData( row, rowMeta.size(), add );\n  }\n\n  private void addToCache( Object[] value ) throws KettleException {\n    try {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/fuzzymatch/FuzzyMatch.java#L159-L195","documentation":"lookupValues resolves the Main Stream Field against the main input row's metadata (getInputRowMeta) and throws this KettleException when the field is not present (indexOfValue < 0). It guards the main-stream side of the fuzzy match, complementing 1471/1472 which guard the lookup stream.","triggerScenarios":"The configured 'Main stream field' is absent from the main input stream's row metadata on the first call to outputRow/lookupValues.","commonSituations":"Upstream step renamed/deleted the main-stream column; wrong field selected in the dialog; a previous transformation in a pipeline chain changed the layout; copy/paste of step config between transformations with different schemas.","solutions":["Re-select the Main stream field in the Fuzzy Match dialog from the actual available columns.","Inspect the main stream layout (preview or 'Input fields') and confirm the field name and spelling.","Fix upstream steps to emit the required field before the Fuzzy Match step.","If a variable supplies the field name, verify it resolves at runtime."],"exampleFix":"// before\nMain stream field: 'cust_name'\n// after (actual main-stream column)\nMain stream field: 'customer_name'","handlingStrategy":"validation","validationCode":"// Before the Fuzzy Match step, assert the main stream field exists:\nint idx = mainRowMeta.indexOfValue(mainStreamFieldName);\nif (idx < 0) {\n  throw new KettleException(\"Main stream field not found: \" + mainStreamFieldName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  outputRow();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"CouldnotFindMainField\")) {\n    logError(\"Main stream field missing — check Fuzzy Match config vs main stream layout: \" + e.getMessage());\n  }\n  throw e;\n}","preventionTips":["Confirm the Main stream field selection after any upstream rename.","Preview the main stream before running the transformation.","Keep field names consistent across steps; avoid manual typing of names.","When chaining transformations, verify schema at each hop boundary."],"tags":["fuzzy-match","main-stream","configuration"],"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"}