{"record":{"id":"954751276820e919","repo":"pentaho/pentaho-kettle","slug":"salesforceinput-errorinsert","errorCode":null,"errorMessage":"SalesforceInput.ErrorInsert","messagePattern":"SalesforceInput\\.ErrorInsert","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java","lineNumber":877,"sourceCode":"  public UpsertResult[] upsert( String upsertField, SObject[] sfBuffer ) throws KettleException {\n    try {\n      return getBinding().upsert( upsertField, sfBuffer );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.ErrorUpsert\", e ) );\n    }\n  }\n\n  public SaveResult[] insert( SObject[] sfBuffer ) throws KettleException {\n    try {\n      List<SObject> normalizedSfBuffer = new ArrayList<>();\n      for ( SObject part : sfBuffer ) {\n        if ( part != null ) {\n          normalizedSfBuffer.add( part );\n        }\n      }\n      return getBinding().create( normalizedSfBuffer.toArray( new SObject[normalizedSfBuffer.size()] ) );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.ErrorInsert\", e ) );\n    }\n  }\n\n  public SaveResult[] update( SObject[] sfBuffer ) throws KettleException {\n    try {\n      return getBinding().update( sfBuffer );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.ErrorUpdate\", e ) );\n    }\n  }\n\n  public DeleteResult[] delete( String[] id ) throws KettleException {\n    try {\n      return getBinding().delete( id );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceInput.ErrorDelete\", e ) );\n    }\n  }","sourceCodeStart":859,"sourceCodeEnd":895,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforce/SalesforceConnection.java#L859-L895","documentation":"KettleException thrown by SalesforceConnection.insert() when the SOAP create() call fails. Like upsert(), the exception text is embedded in the message rather than as a cause. Records are first normalized into SObjects; any transport/API failure during create() triggers this error.","triggerScenarios":"Calling insert(sfBuffer) when the binding's create() throws: invalid session, malformed SObject (bad field/value), missing create permission, or an empty/oversized batch rejected by the API.","commonSituations":"Required Salesforce fields missing in the incoming rows, picklist/lookup values not matching existing records, API user lacking Create permission, sending more records than the SOAP batch limits allow.","solutions":["Read the embedded Salesforce fault in the message for the exact record/field error","Ensure all required fields (and required-by-validation-rule fields) are populated","Verify Create object permission for the integration user","Check field value formats (dates ISO 8601, valid picklist values, valid lookup IDs)","Split large buffers into smaller batches (connection.setRowsInBatch)"],"exampleFix":"// before\nSaveResult[] r = connection.insert(buffer); // missing required Name\n// after\n// populate required fields on each SObject first\nSaveResult[] r = connection.insert(buffer);\nfor (SaveResult res : r) if (!res.isSuccess()) handleErrors(res.getErrors());","handlingStrategy":"validation","validationCode":"if (sfBuffer == null || sfBuffer.length == 0) throw new IllegalArgumentException(\"Empty insert buffer\"); // also pre-check required fields via getFields() metadata","typeGuard":"boolean insertReady(SObject[] buf) { return buf != null && buf.length > 0 && Arrays.stream(buf).allMatch(o -> o != null && o.getType() != null); }","tryCatchPattern":"try { results = connection.insert(buffer); } catch (KettleException e) { log.logError(\"Insert failed: \" + e.getMessage(), e); throw e; } // fault text is in e.getMessage()","preventionTips":["Populate all required fields (and validation-rule-required fields) before insert","Verify Create permission for the API user","Match Salesforce field formats: ISO 8601 dates, valid picklist values, existing lookup Ids","Iterate SaveResult[] and handle per-record errors rather than assuming batch success","Keep batches within Salesforce SOAP size limits (use setRowsInBatch)"],"tags":["salesforce","insert","api","data"],"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"}