{"record":{"id":"013af9bbd15be4a8","repo":"pentaho/pentaho-kettle","slug":"salesforcedelete-error-writetosalesforce","errorCode":null,"errorMessage":"SalesforceDelete.Error.WriteToSalesforce","messagePattern":"SalesforceDelete\\.Error\\.WriteToSalesforce","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforcedelete/SalesforceDelete.java","lineNumber":119,"sourceCode":"      }\n\n      // if there is room in the buffer\n      if ( data.iBufferPos < meta.getBatchSizeInt() ) {\n\n        // Load the buffer array\n        data.deleteId[data.iBufferPos] = getInputRowMeta().getString( rowData, data.indexOfKeyField );\n        data.outputBuffer[data.iBufferPos] = rowData;\n        data.iBufferPos++;\n      }\n\n      if ( data.iBufferPos >= meta.getBatchSizeInt() ) {\n        if ( log.isDetailed() ) {\n          logDetailed( BaseMessages.getString( PKG, \"SalesforceDelete.Log.CallingFlush\" ) );\n        }\n        flushBuffers();\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"SalesforceDelete.Error.WriteToSalesforce\", e\n        .getMessage() ) );\n    }\n  }\n\n  private void flushBuffers() throws KettleException {\n\n    try {\n      if ( data.deleteId.length > data.iBufferPos ) {\n        String[] smallBuffer = new String[data.iBufferPos];\n        System.arraycopy( data.deleteId, 0, smallBuffer, 0, data.iBufferPos );\n        data.deleteId = smallBuffer;\n      }\n      // delete the object(s) by sending the array to the web service\n      data.deleteResult = data.connection.delete( data.deleteId );\n      int nr = data.deleteResult.length;\n      for ( int j = 0; j < nr; j++ ) {\n        if ( data.deleteResult[j].isSuccess() ) {\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/salesforce/core/src/main/java/org/pentaho/di/trans/steps/salesforcedelete/SalesforceDelete.java#L101-L137","documentation":"writeToSalesForce catches any exception raised while sending buffered rows to Salesforce and rethrows it as a KettleException with this message including the underlying error text. It signals that the write/delete operation against Salesforce failed during execution of the step.","triggerScenarios":"Any failure inside the write path: building/sending the delete call, flushing buffers (flushBuffers), or Salesforce returning an error response while processing the batch.","commonSituations":"Invalid or expired Salesforce session; batch containing malformed IDs; Salesforce API limits hit mid-transformation; network failure while calling the SOAP API.","solutions":["Read the embedded message for the underlying Salesforce error (e.g. INVALID_SESSION_ID, MALFORMED_ID)","Re-authenticate / refresh the Salesforce connection if the session expired","Validate that all input ID values are well-formed 15/18-char Salesforce IDs","Reduce the batch size in the step settings and retry if limits or timeouts are involved"],"exampleFix":"// before: IDs from upstream may be malformed\nrow[0] = someFreeTextField;\n// after: validate ID format before writing to the delete step\nif (!(someFreeTextField instanceof String) || !((String) someFreeTextField).matches(\"[a-zA-Z0-9]{15}([a-zA-Z0-9]{3})?\")) {\n  throw new KettleException(\"Invalid Salesforce ID: \" + someFreeTextField);\n}\nrow[0] = someFreeTextField;","handlingStrategy":"try-catch","validationCode":"// validate IDs before they reach the delete step\nfor (Object id : idColumn) {\n  if (!(id instanceof String) || !((String) id).matches(\"[a-zA-Z0-9]{15}([a-zA-Z0-9]{3})?\")) {\n    throw new IllegalArgumentException(\"Invalid Salesforce ID: \" + id);\n  }\n}","typeGuard":"boolean isValidSalesforceId(Object o) {\n  return o instanceof String && ((String) o).matches(\"[a-zA-Z0-9]{15}([a-zA-Z0-9]{3})?\");\n}","tryCatchPattern":"try {\n  writeToSalesForce(rowData);\n} catch (KettleException e) {\n  logError(\"Salesforce write failed: \" + e.getMessage());\n  if (e.getMessage().contains(\"INVALID_SESSION_ID\")) {\n    connection.reconnect();\n  }\n  throw e;\n}","preventionTips":["Validate all record IDs (15/18-char) upstream with a Filter or Regex step","Keep sessions alive; re-authenticate on INVALID_SESSION_ID","Tune batchSize to stay within Salesforce API limits","Test the delete against a sandbox before production"],"tags":["salesforce","delete","api-write","batch"],"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"}