{"record":{"id":"8dfa981f43055bee","repo":"pentaho/pentaho-kettle","slug":"clonerow-log-nrclonesisnull","errorCode":null,"errorMessage":"CloneRow.Log.NrClonesIsNull","messagePattern":"CloneRow\\.Log\\.NrClonesIsNull","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/clonerow/CloneRow.java","lineNumber":131,"sourceCode":"      outputRowData = RowDataUtil.createResizedCopy( r, data.outputRowMeta.size() );\n      int rowIndex = data.NrPrevFields;\n      if ( meta.isAddCloneFlag() ) {\n        // This row is not a clone but the original row\n        outputRowData[ rowIndex ] = false;\n        rowIndex++;\n      }\n      if ( meta.isAddCloneNum() ) {\n        // This row is the original so let's identify it as the first one (zero)\n        outputRowData[ rowIndex ] = 0L;\n      }\n    }\n\n    putRow( data.outputRowMeta, outputRowData ); // copy row to output rowset(s);\n\n    if ( meta.isNrCloneInField() ) {\n      Long nrCloneFieldValue = getInputRowMeta().getInteger( r, data.indexOfNrCloneField );\n      if ( nrCloneFieldValue == null ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"CloneRow.Log.NrClonesIsNull\" ) );\n      } else {\n        data.nrclones = nrCloneFieldValue;\n        if ( log.isDebug() ) {\n          logDebug( BaseMessages.getString( PKG, \"CloneRow.Log.NrClones\", \"\" + data.nrclones ) );\n        }\n      }\n    }\n    for ( int i = 0; i < data.nrclones && !isStopped(); i++ ) {\n      // Output now all clones row\n      outputRowData = r.clone();\n      if ( data.addInfosToRow ) {\n        // We need here to add more infos about clone rows\n        outputRowData = RowDataUtil.createResizedCopy( r, data.outputRowMeta.size() );\n        int rowIndex = data.NrPrevFields;\n        if ( meta.isAddCloneFlag() ) {\n          // This row is a clone row\n          outputRowData[ rowIndex ] = true;\n          rowIndex++;","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/clonerow/CloneRow.java#L113-L149","documentation":"After emitting the original row, CloneRow reads the clone-count field from the current row via getInteger(). If that field's value is null it throws this KettleException ('NrClones is null'), since the number of clones cannot be determined.","triggerScenarios":"processRow with isNrCloneInField()==true where getInputRowMeta().getInteger(r, indexOfNrCloneField) returns null — the field exists but holds NULL for this row.","commonSituations":"Upstream steps (table input, JSON input, optional joins) producing NULL in the count column; using a field of a type that converts to null; forgetting a default/replace-null step.","solutions":["Prepend a 'Replace null values' (or IF/Value Mapper) step to default the count field to 0 or a valid number before CloneRow","Fix the upstream step so the count field is always populated (e.g. NVL/count(*) in SQL)","Filter out or handle rows with NULL counts before CloneRow","Coerce the field to Integer type upstream so getInteger never yields null"],"exampleFix":"// SQL upstream\n// before: SELECT maybe_null_cnt AS clone_count FROM t\n// after:  SELECT NVL(maybe_null_cnt, 0) AS clone_count FROM t","handlingStrategy":"validation","validationCode":"Object v = inputRowMeta.getInteger(row, idx);\nif (v == null) {\n  // route row to error handling or default it before CloneRow\n  v = 0L;\n}","typeGuard":null,"tryCatchPattern":"catch (KettleException e) { if (e.getMessage().contains(\"NrClonesIsNull\")) { add Replace-null upstream and rerun; } }","preventionTips":["Use NVL/COALESCE in upstream SQL for count fields","Add a Replace null values step before CloneRow","Ensure the count field is typed Integer in the stream"],"tags":["kettle","clone-row","null-value"],"backgroundTag":"null-argument","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"}