{"record":{"id":"28cd7b1d2d4eb872","repo":"pentaho/pentaho-kettle","slug":"clonerow-exception-couldnotfindfield","errorCode":null,"errorMessage":"CloneRow.Exception.CouldnotFindField","messagePattern":"CloneRow\\.Exception\\.CouldnotFindField","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/clonerow/CloneRow.java","lineNumber":95,"sourceCode":"          logError( BaseMessages.getString( PKG, \"CloneRow.Error.CloneNumFieldMissing\" ) );\n          throw new KettleException( BaseMessages.getString( PKG, \"CloneRow.Error.CloneNumFieldMissing\" ) );\n        }\n      }\n\n      if ( meta.isNrCloneInField() ) {\n        String cloneinfieldname = meta.getNrCloneField();\n        if ( Utils.isEmpty( cloneinfieldname ) ) {\n          logError( BaseMessages.getString( PKG, \"CloneRow.Error.NrCloneInFieldMissing\" ) );\n          throw new KettleException( BaseMessages.getString( PKG, \"CloneRow.Error.NrCloneInFieldMissing\" ) );\n        }\n        // cache the position of the field\n        if ( data.indexOfNrCloneField < 0 ) {\n          data.indexOfNrCloneField = getInputRowMeta().indexOfValue( cloneinfieldname );\n          if ( data.indexOfNrCloneField < 0 ) {\n            // The field is unreachable !\n            logError( BaseMessages.getString( PKG, \"CloneRow.Log.ErrorFindingField\" )\n              + \"[\" + cloneinfieldname + \"]\" );\n            throw new KettleException( BaseMessages.getString(\n              PKG, \"CloneRow.Exception.CouldnotFindField\", cloneinfieldname ) );\n          }\n        }\n      } else {\n        String nrclonesString = environmentSubstitute( meta.getNrClones() );\n        data.nrclones = Const.toInt( nrclonesString, 0 );\n        if ( log.isDebug() ) {\n          logDebug( BaseMessages.getString( PKG, \"CloneRow.Log.NrClones\", \"\" + data.nrclones ) );\n        }\n      }\n    }\n\n    Object[] outputRowData = r;\n\n    if ( data.addInfosToRow ) {\n      // It's the original row..\n      // We need here to add some infos in order to identify this row\n      outputRowData = RowDataUtil.createResizedCopy( r, data.outputRowMeta.size() );","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/clonerow/CloneRow.java#L77-L113","documentation":"When the clone count comes from an input field, CloneRow looks up that field's index in the incoming row meta. If the configured field does not exist in the stream, it logs 'Error finding field' and throws this KettleException with the field name.","triggerScenarios":"processRow with isNrCloneInField()==true where getInputRowMeta().indexOfValue(cloneinfieldname) returns -1 — the field is absent from the upstream stream.","commonSituations":"Renaming or removing the source field upstream (Select values / change of preceding step); typo in the field name; a variable-hop (Get variables) step reordering the stream; field only present conditionally.","solutions":["Add/fix the field in the upstream stream (e.g. via a 'Get variables' or 'User Defined Java Expression' step) before CloneRow","Correct the 'nr clones in field' name in the CloneRow dialog to match the actual stream field","Use Specified order / Select values to ensure the field is present and named consistently","Inspect the incoming row layout (preview) to confirm the field exists"],"exampleFix":"// before\ncloneRowMeta.setNrCloneField( \"cln_cnt\" ); // stream has \"clone_count\"\n// after\ncloneRowMeta.setNrCloneField( \"clone_count\" );","handlingStrategy":"validation","validationCode":"String f = meta.getNrCloneField();\nif (!inputRowMeta.indexOfValue(f).isEmptyOrMinusOne) { /* pseudo */ }\n// actual:\nif (inputRowMeta.indexOfValue(f) < 0) {\n  throw new IllegalArgumentException(\"Field not in stream: \" + f);\n}","typeGuard":null,"tryCatchPattern":"catch (KettleException e) { if (e.getMessage().contains(\"CouldnotFindField\")) { log which upstream step dropped the field; } }","preventionTips":["Preview upstream rows to confirm field names before configuring CloneRow","Avoid renaming fields upstream without updating downstream steps","Use Select values to pin field names/order"],"tags":["kettle","clone-row","stream-fields"],"backgroundTag":"record-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"}