James Netherton created CAMEL-27901:
---------------------------------------

             Summary: camel-salesforce: Bulk API PK chunking with options is 
rejected by Salesforce
                 Key: CAMEL-27901
                 URL: https://issues.apache.org/jira/browse/CAMEL-27901
             Project: Camel
          Issue Type: Bug
          Components: camel-salesforce
            Reporter: James Netherton
            Assignee: James Netherton


Creating a Bulk API job with PK chunking and a chunk size fails. This is how 
{{BulkApiQueryManualIT.testPkChunking}} fails against a scratch org:

{noformat}
org.apache.camel.component.salesforce.api.SalesforceException:
{errors:[{"errorCode":"ClientInputError","message":"Sforce-Enable-PkChunking 
doesn't have a valid value.","fields":null}],statusCode:400}
    at 
...DefaultBulkApiClient.createRestException(DefaultBulkApiClient.java:434)
    ...
    at ...BulkApiQueryManualIT.testPkChunking(BulkApiQueryManualIT.java:99)
{noformat}

The test sets {{CamelSalesforcePkChunking=true}} and 
{{CamelSalesforcePkChunkingChunkSize=1000}}.

{{BulkApiProcessor.determineHeaders}} builds the {{Sforce-Enable-PKChunking}} 
header as a list of separate values, {{["true", "chunkSize=1000"]}}, plus 
{{startRow=...}} and {{parent=...}} when set. Jetty sends the list either as 
several header lines or as one line joined with commas. Salesforce expects a 
single value: {{TRUE}}, or options separated by semicolons, for example 
{{chunkSize=1000; startRow=00130000000xEftMGH}}.

Impact: any route that uses {{pkChunking}} together with 
{{pkChunkingChunkSize}}, {{pkChunkingStartRow}} or {{pkChunkingParent}} fails 
to create the job. {{pkChunking}} on its own probably still works, since only 
{{true}} is sent.

The code dates from CAMEL-12808 (2021). Either Salesforce has become stricter 
about the header, or the Jetty upgrade changed how list-valued headers are sent.

Proposed fix: send one header value, the options joined with {{"; "}}, or 
{{TRUE}} when there are none, and add a unit test for the header value.





--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to