{"record":{"id":"5a3eab96384a1070","repo":"pentaho/pentaho-kettle","slug":"salesforceinsert-failedtoinsertobject","errorCode":null,"errorMessage":"SalesforceInsert.FailedToInsertObject","messagePattern":"SalesforceInsert\\.FailedToInsertObject","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforceinsert/SalesforceInsert.java","lineNumber":250,"sourceCode":"\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\" );\n\n        }\n\n      }\n\n      // reset the buffers\n      data.sfBuffer = new SObject[meta.getBatchSizeInt()];\n      data.outputBuffer = new Object[meta.getBatchSizeInt()][];\n      data.iBufferPos = 0;\n\n    } catch ( Exception e ) {\n      if ( !getStepMeta().isDoingErrorHandling() ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInsert.FailedToInsertObject\", e\n          .getMessage() ) );\n      }\n      // Simply add this row to the error row\n      if ( log.isDebug() ) {\n        logDebug( \"Passing row to error step\" );\n      }\n\n      for ( int i = 0; i < data.iBufferPos; i++ ) {\n        putError( data.inputRowMeta, data.outputBuffer[i], 1, e.getMessage(), null, \"SalesforceInsert002\" );\n      }\n    } finally {\n      if ( data.saveResult != null ) {\n        data.saveResult = null;\n      }\n    }\n\n  }\n","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforceinsert/SalesforceInsert.java#L232-L268","documentation":"At the end of flushBuffers(), after an Exception occurs, the step either routes the row to error handling or throws KettleException 'Failed to insert object' with e.getMessage(). The throw happens only when the step is NOT configured with error handling (getStepMeta().isDoingErrorHandling() is false).","triggerScenarios":"Exception during Salesforce insert/buffer flush with no error-handling configured: SOAP fault, connection failure, or invalid SObject data on the row being flushed.","commonSituations":"Records failing Salesforce validation rules on a plain run without error handling; session expired mid-batch; network interruption during flush; developers running transformations without error streams configured.","solutions":["Configure step error handling (error stream with ' Nr of errors' settings) so failures are captured instead of aborting — this bypasses the throw","Fix the data/Salesforce error in the wrapped cause, then rerun","Enable detailed logging to see which row/record failed and why","Validate record payloads against Salesforce field requirements before the step"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if (!stepMeta.isDoingErrorHandling()) {\n  log.warn(\"SalesforceInsert has no error handling; any insert failure will abort the transformation\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  log.error(\"Insert failed (no error handling configured): {}\", root.getMessage(), root);\n}","preventionTips":["Configure an error-handling target step on Salesforce Insert so errors divert instead of throwing","Validate record payloads against Salesforce schema before batch flush","Monitor Salesforce session validity for long-running jobs"],"tags":["salesforce","error-handling","batch","soap"],"backgroundTag":"api-request-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"}