{"record":{"id":"10e94bcf4c36cb41","repo":"pentaho/pentaho-kettle","slug":"salesforceinsert-error-flushbuffer","errorCode":null,"errorMessage":"SalesforceInsert.Error.FlushBuffer","messagePattern":"SalesforceInsert\\.Error\\.FlushBuffer","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforceinsert/SalesforceInsert.java","lineNumber":219,"sourceCode":"              logDetailed( BaseMessages.getString( PKG, \"SalesforceInsert.log.LineRow\", getLinesInput() ) );\n            }\n          }\n\n        } else {\n          // there were errors during the create call, go through the\n          // errors\n          // array and write them to the screen\n\n          if ( !getStepMeta().isDoingErrorHandling() ) {\n\n            if ( log.isDebug() ) {\n              logDebug( BaseMessages.getString( PKG, \"SalesforceInsert.ErrorFound\" ) );\n            }\n\n            // Only show the first error\n            //\n            com.sforce.soap.partner.Error err = data.saveResult[j].getErrors()[0];\n            throw new KettleException( BaseMessages\n              .getString( PKG, \"SalesforceInsert.Error.FlushBuffer\", new Integer( j ), err.getStatusCode(), err\n                .getMessage() ) );\n          }\n\n          String errorMessage = \"\";\n          for ( int i = 0; i < data.saveResult[j].getErrors().length; i++ ) {\n            // get the next error\n            com.sforce.soap.partner.Error err = data.saveResult[j].getErrors()[i];\n            errorMessage +=\n              BaseMessages.getString( PKG, \"SalesforceInsert.Error.FlushBuffer\", new Integer( j ), err\n                .getStatusCode(), err.getMessage() );\n          }\n\n          // Simply add this row to the error row\n          if ( log.isDetailed() ) {\n            logDetailed( BaseMessages.getString( PKG, \"SalesforceInsert.PassingRowToErrorStep\" ) );\n          }\n          putError( getInputRowMeta(), data.outputBuffer[j], 1, errorMessage, null, \"SalesforceInsert001\" );","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforceinsert/SalesforceInsert.java#L201-L237","documentation":"flushBuffers() sends the buffered SObjects to Salesforce and inspects each SaveResult. If a SaveResult reports success=false, the step reads the first com.sforce.soap.partner.Error and throws KettleException 'Error.FlushBuffer' including the row index (j), the status code, and the Salesforce error message. It is raised only when error handling is not enabled for the failing record path (first-error-only behavior).","triggerScenarios":"Salesforce rejects a record in the batch: e.g. INVALID_FIELD, REQUIRED_FIELD_MISSING, DUPLICATES_DETECTED, malformed external id, or record locked. Any saveResult[j].getSuccess()==false triggers this with the first error only.","commonSituations":"Inserting records missing required Salesforce fields; invalid picklist values; hitting validation rules; duplicate rules blocking inserts; permission issues on the object.","solutions":["Read the status code/message in the error text — it is the actual Salesforce API rejection reason","Fix the offending data (required fields, picklist values, duplicates) before re-running","Configure step error handling so failed records go to an error stream instead of stopping the transformation","Log all errors per record instead of only the first (the code truncates to getErrors()[0])"],"exampleFix":"// before\ncom.sforce.soap.partner.Error err = data.saveResult[j].getErrors()[0];\n// after (log all errors)\nfor (com.sforce.soap.partner.Error err : data.saveResult[j].getErrors()) {\n  logError(err.getStatusCode() + \": \" + err.getMessage());\n}","handlingStrategy":"validation","validationCode":"// Validate required Salesforce fields exist and picklist values are legal before insert\nif (sobject.getField(\"Name\") == null) {\n  throw new IllegalArgumentException(\"REQUIRED_FIELD_MISSING: Name\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  // message embeds row index + status code, e.g. REQUIRED_FIELD_MISSING\n  log.error(\"Salesforce rejected record: {}\", e.getMessage(), e);\n}\n// Better: attach an error-handling step so failures route to an error stream","preventionTips":["Read the embedded status code in the message — it is the authoritative Salesforce rejection reason","Pre-validate records against required fields, picklists, and duplicate rules","Configure the step's error handling target so single record failures do not kill the batch"],"tags":["salesforce","soap","save-result","validation"],"backgroundTag":"api-error-response","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"}