{"record":{"id":"64fcbde4c4a7c730","repo":"pentaho/pentaho-kettle","slug":"failed-in-writetosalesforce","errorCode":null,"errorMessage":"\nFailed in writeToSalesForce: ","messagePattern":"\nFailed in writeToSalesForce: ","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforceupdate/SalesforceUpdate.java","lineNumber":166,"sourceCode":"        if ( fieldsToNull.size() > 0 ) {\n          // Set Null to fields\n          sobjPass.setFieldsToNull( fieldsToNull.toArray( new String[fieldsToNull.size()] ) );\n        }\n\n        // Load the buffer array\n        data.sfBuffer[data.iBufferPos] = sobjPass;\n        data.outputBuffer[data.iBufferPos] = rowData;\n        data.iBufferPos++;\n      }\n\n      if ( data.iBufferPos >= meta.getBatchSizeInt() ) {\n        if ( log.isDetailed() ) {\n          logDetailed( \"Calling flush buffer from writeToSalesForce\" );\n        }\n        flushBuffers();\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( \"\\nFailed in writeToSalesForce: \" + e.getMessage() );\n    }\n  }\n\n  private void flushBuffers() throws KettleException {\n\n    try {\n      if ( data.sfBuffer.length > data.iBufferPos ) {\n        SObject[] smallBuffer = new SObject[data.iBufferPos];\n        System.arraycopy( data.sfBuffer, 0, smallBuffer, 0, data.iBufferPos );\n        data.sfBuffer = smallBuffer;\n      }\n      // update the object(s) by sending the array to the web service\n      data.saveResult = data.connection.update( data.sfBuffer );\n      int nr = data.saveResult.length;\n      for ( int j = 0; j < nr; j++ ) {\n        if ( data.saveResult[j].isSuccess() ) {\n          // Row was updated\n          String id = data.saveResult[j].getId();","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforceupdate/SalesforceUpdate.java#L148-L184","documentation":"writeToSalesForce() wraps its buffer management and flush logic in a try/catch and rethrows as KettleException('\\\\nFailed in writeToSalesForce: ' + e.getMessage()). It aggregates any failure while preparing or flushing the Salesforce update batch. Note it keeps only e.getMessage(), so the exception class and stack are lost — a known debugging pain point.","triggerScenarios":"Called from processRow per row (and from unit tests): exceptions while adding an SObject to the buffer or calling flushBuffers() — Salesforce API errors, connection failures, or internal NPEs.","commonSituations":"Batch update failing because of Salesforce API limits or bad field data; session timeout mid-batch; misconfigured batchSize leading to oversized requests.","solutions":["Read the appended message after 'Failed in writeToSalesForce:' for the root Salesforce error text.","Check step log output at detailed level for the specific SObject row being written.","Validate field values/types sent to Salesforce (nulls, external-ID fields) — see errors 3747/3748 for the underlying flush failures.","If diagnostics are unclear, enable detailed logging or patch the catch to pass the whole exception as cause."],"exampleFix":"// before: cause and stacktrace are dropped\nthrow new KettleException( \"\\nFailed in writeToSalesForce: \" + e.getMessage() );\n// after: keep the cause for diagnosis\nthrow new KettleException( \"\\nFailed in writeToSalesForce\", e );","handlingStrategy":"try-catch","validationCode":"// Sanity-check batchSize and field data before executing the step\nif (meta.getBatchSizeInt() <= 0 || meta.getBatchSizeInt() > 10000) {\n  throw new IllegalArgumentException(\"Invalid batchSize: \" + meta.getBatchSizeInt());\n}","typeGuard":null,"tryCatchPattern":"try {\n  step.processRow();\n} catch (KettleException e) {\n  // message is 'Failed in writeToSalesForce: <root msg>' — parse and also check step logs\n  log.error(\"writeToSalesForce failure: {}\", e.getMessage());\n}","preventionTips":["Enable detailed logging on the step to capture per-row context the message drops.","Keep batchSize moderate to avoid oversized Salesforce requests.","Prefer fixed builds where the cause is preserved (the catch drops the stacktrace).","Validate field values (nulls, Id formats) before the batch is built."],"tags":["kettle","salesforce","batch-write","diagnostics"],"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"}