davsclaus commented on code in PR #31250:
URL: https://github.com/apache/camel/pull/31250#discussion_r4769535295
##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/AbstractClientBase.java:
##########
@@ -178,6 +179,48 @@ protected Request getRequest(String method, String url,
Map<String, List<String>
return request;
}
+ /**
+ * Resolves the request URL for a path that is relative to the configured
Salesforce instance and verifies that it
+ * stays on that instance. The {@code relativePath} must be an absolute
path (it has to begin with a single
+ * {@code /}), and the fully resolved URL must keep the scheme, host and
port of the configured instance URL.
+ * Operations that build a request URL by appending a caller-supplied path
onto {@link #instanceUrl} use this to
+ * keep the request on the configured instance.
+ *
+ * @param relativePath the path to append to the configured
instance URL
+ * @return the fully resolved request URL
+ * @throws SalesforceException if {@code relativePath} is not an absolute
path on the configured instance
+ */
+ protected String resolveInstanceUrl(String relativePath) throws
SalesforceException {
+ if (relativePath == null || !relativePath.startsWith("/") ||
relativePath.startsWith("//")) {
+ throw new SalesforceException(
+ "Request path must be an absolute path on the configured
Salesforce instance: " + relativePath);
+ }
+ final String requestUrl = instanceUrl + relativePath;
Review Comment:
Accepted as a follow-up. `instanceUrl` is only null before the login has
completed. Both callers of `resolveInstanceUrl` (`DefaultRawClient.makeRequest`
and `DefaultRestClient.queryMore`) are called from processors that catch it:
`RawProcessor` catches `Exception`, and `AbstractRestProcessor` catches
`RuntimeException`. In both cases the exchange fails with the NPE and does not
hang. Before this PR such a request went to `null/<path>` and failed as well. A
null guard with a clearer `SalesforceException` would be nice, but it does not
block this PR.
_Claude Code on behalf of davsclaus_
##########
components/camel-salesforce/camel-salesforce-component/src/main/java/org/apache/camel/component/salesforce/internal/client/DefaultRestClient.java:
##########
@@ -630,6 +639,18 @@ private String urlEncode(String query) throws
UnsupportedEncodingException {
return encodedQuery;
}
+ private String encodePathSegment(String value) {
+ if (value == null || value.isEmpty()) {
+ throw new IllegalArgumentException("The record id must not be null
or empty");
Review Comment:
No effect in practice: `AbstractRestProcessor.process` catches
`RuntimeException` and sets a `SalesforceException` ("Unexpected Error
processing ...") on the exchange, so a null or empty id still fails the
exchange cleanly. For `updateSObjectMultipart` the IAE is already routed
through the callback. Routing it through the callback in the other four methods
is fine as a follow-up.
_Claude Code on behalf of davsclaus_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]