{"record":{"id":"e9611b0bf0516238","repo":"pentaho/pentaho-kettle","slug":"errors-encountered-first-10","errorCode":null,"errorMessage":"Errors encountered (first 10): ...","messagePattern":"Errors encountered \\(first 10\\): \\.\\.\\.","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java","lineNumber":346,"sourceCode":"      updateCounts = be.getUpdateCounts();\n      exceptionsList = be.getExceptionsList();\n\n      if ( getStepMeta().isDoingErrorHandling() ) {\n        data.db.clearBatch( insertStatement );\n        data.db.commit( true );\n      } else {\n        data.db.clearBatch( insertStatement );\n        data.db.rollback();\n        StringBuilder msg = new StringBuilder( \"Error batch inserting rows into table [\" + tableName + \"].\" );\n        msg.append( Const.CR );\n        msg.append( \"Errors encountered (first 10):\" ).append( Const.CR );\n        for ( int x = 0; x < be.getExceptionsList().size() && x < 10; x++ ) {\n          Exception exception = be.getExceptionsList().get( x );\n          if ( exception.getMessage() != null ) {\n            msg.append( exception.getMessage() ).append( Const.CR );\n          }\n        }\n        throw new KettleException( msg.toString(), be );\n      }\n    } catch ( KettleDatabaseException dbe ) {\n      if ( getStepMeta().isDoingErrorHandling() ) {\n        if ( isRowLevel() ) {\n          logRowlevel( \"Written row to error handling : \" + getInputRowMeta().getString( r ) );\n        }\n\n        if ( data.useSafePoints ) {\n          data.db.rollback( data.savepoint );\n          if ( data.releaseSavepoint ) {\n            data.db.releaseSavepoint( data.savepoint );\n          }\n          // data.db.commit(true); // force a commit on the connection too.\n        }\n\n        sendToErrorRow = true;\n        errorMessage = dbe.toString();\n      } else {","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java#L328-L364","documentation":"When error handling is enabled and a batch insert fails, the step collects up to the first 10 individual exceptions from the KettleDatabaseBatchException and rethrows them as a single KettleException summarizing the batch failure. This is the aggregated report of which rows/statements in the batch failed.","triggerScenarios":"A KettleDatabaseBatchException is caught, getStepMeta().isDoingErrorHandling() is true, batchProblem is set, and the step builds a message with the first 10 exceptions from be.getExceptionsList() before rethrowing.","commonSituations":"Batch insert with multiple bad rows (duplicate keys, constraint violations, truncations); error handling configured but data quality issues present; commit size large so many rows fail per batch.","solutions":["Parse the listed messages to identify and fix the offending rows in the source data.","Reduce commit size so fewer rows fail per batch and error rows are more precisely identified.","Disable batch mode to get exact per-row error handling and use the error hop to route bad rows.","Add data-cleansing steps (dedupe, type validation) upstream."],"exampleFix":"// before: batch mode + error handling, 10 rows with duplicate PKs fail together\n// after: uncheck 'Use batch update' so failing rows go individually to the error hop","handlingStrategy":"try-catch","validationCode":"// Validate rows before batch insert to avoid multi-row batch failures\nfor ( Object[] row : rows ) { validateRowAgainstSchema( row, tableSchema ); }","typeGuard":null,"tryCatchPattern":"try {\n  writeToTable( row );\n} catch ( KettleException e ) {\n  if ( e.getMessage().startsWith( \"Errors encountered (first 10)\" ) ) {\n    for ( String line : e.getMessage().split( Const.CR ) ) logFailedRow( line );\n    // replay failing rows individually for precise error handling\n  }\n}","preventionTips":["Combine batch mode with a configured error hop only if you accept coarse row identification","Cleanse/deduplicate data before batch loads","Use smaller commit sizes when per-row diagnostics matter"],"tags":["kettle","table-output","batch","error-handling"],"backgroundTag":"database-write-failed","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"}