Repository navigation
[Cherrypick] Fix IndexOutOfBoundsException in SalesforceWideRecordReader and Handled HTML based error response - #371
Conversation
… query returns empty results Surface HTTP status and readable error message for non-JSON Salesforce OAuth responses
There was a problem hiding this comment.
Code Review
This pull request updates the project version to 1.7.5, improves Salesforce OAuth authentication error handling by parsing HTML error pages when JSON parsing fails, and prevents errors in SalesforceWideRecordReader when dealing with empty batches. The feedback recommends improving the robustness of the HTML parsing logic: first, by allowing optional whitespace around the assignment operator in the id="error" attribute regex, and second, by using a more precise regex to strip HTML tags to avoid accidentally removing legitimate text containing mathematical comparison operators.
Sunish-Dahiya
left a comment
There was a problem hiding this comment.
Can you please make the PR description better, add test reports and ensure all e2e tests are passing
043b994
into
data-integrations:release/1.7
check batchIterator.hasNext() before calling fetchBatchRecords() during SalesforceWideRecordReader.initialize() and default results to an empty list when no partitions exist, preventing an IndexOutOfBoundsException when the bulk query returns zero records.
extractErrorFromResponse checks a non-JSON OAuth response for an HTML error block (<div ... id="error" ...>...), strips any inner HTML tags to return just the plain-text error message (e.g., "Error: Please enter your username."), and falls back to "Error while authenticating to Salesforce with given credentials." if none is found—avoiding dumping the full raw HTML page into the exception message.
Testing Details
Setup: Created a custom object (Wide_Empty_Object__c) with 500 fields (generating a >20,000-character query) and 0 records, and ran prepareQuery and readPartition (plus added a unit test in SalesforceWideRecordReaderTest).
Before Fix:
readPartition failed when reading the empty wide object: =
After Fix:
readPartition handles the empty batch gracefully and completes with 0 records:
cherry-picked from: #367