Claus Ibsen created CAMEL-28054:
-----------------------------------

             Summary: camel-salesforce - encode the id segments of the Bulk, 
Bulk V2 and Analytics clients, and error handling follow-ups of CAMEL-28020
                 Key: CAMEL-28054
                 URL: https://issues.apache.org/jira/browse/CAMEL-28054
             Project: Camel
          Issue Type: Improvement
          Components: camel-salesforce
            Reporter: Claus Ibsen
             Fix For: 4.25.0


Follow-up of CAMEL-28020 (PR https://github.com/apache/camel/pull/31250), which 
validates the REST and raw client request URLs and encodes the record id in the 
sObject URLs of {{DefaultRestClient}}. These points came up during review and 
were left out to keep that change small.

h4. 1. Id segments that are still not encoded

These values are added to the request URL without encoding them as a path 
segment. {{DefaultRestClient}} has a private {{encodePathSegment}} (since 
CAMEL-28020) that can be reused or moved to {{AbstractClientBase}}.

* {{DefaultBulkApiClient}}: {{jobUrl}} ({{jobId}}), {{batchUrl}} ({{batchId}}), 
{{batchResultUrl}} ({{resultId}}), around lines 491-507
* {{DefaultBulkApiV2Client}}: the ingest and query job URLs ({{jobId}}), around 
lines 323-329
* {{DefaultAnalyticsApiClient}}: {{reportsUrl}} and {{reportInstancesUrl}} 
({{reportId}}, {{instanceId}}), around lines 228-247
* {{DefaultRestClient.getBlobField}}: {{blobFieldName}} (around line 419)
* {{DefaultRestClient.getEventSchemaBySchemaId}}: {{schemaId}} (around line 
554), and the {{payloadFormat}} query parameter on the same line

Add a test per client that an id with a {{/}} is sent as {{%2F}}, as 
{{DefaultRestClientRequestUrlTest}} does for the sObject id.

h4. 2. A null instanceUrl gives a NullPointerException

{{AbstractClientBase.resolveInstanceUrl}} (used by 
{{DefaultRawClient.makeRequest}} and {{DefaultRestClient.queryMore}}) calls 
{{new URI(instanceUrl)}} and catches only {{URISyntaxException}}. When the 
login has not completed yet, {{instanceUrl}} is null and the request fails with 
a NullPointerException instead of a {{SalesforceException}} that says why. The 
exchange still fails, as the processors catch it. Proposed: check for a null 
{{instanceUrl}} first and throw a {{SalesforceException}}, which the callers 
already pass to the callback.

h4. 3. The error for a null or empty id does not go through the callback

{{DefaultRestClient.encodePathSegment}} throws an {{IllegalArgumentException}} 
for a null or empty id. {{updateSObjectMultipart}} passes it to the 
{{ResponseCallback}}, but {{getSObject}}, {{updateSObject}}, {{deleteSObject}} 
and {{getBlobField}} throw it to the caller. {{AbstractRestProcessor.process}} 
turns it into a {{SalesforceException}} on the exchange, so the exchange fails 
cleanly, but the other errors of the client go through the callback. Proposed: 
catch it in these four methods and call the callback with a 
{{SalesforceException}}, as the other error paths do.

----
_Filed by Claude Code on behalf of davsclaus_




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

Reply via email to