Skip to content

[Cherrypick] Fix IndexOutOfBoundsException in SalesforceWideRecordReader and Handled HTML based error response - #371

Merged
vikasrathee-cs merged 2 commits into
data-integrations:release/1.7from
Ashutosh-Jarvis:cherrypick-fix-indexoutofbound-exception
Oct 30, 2026
Merged

vikasrathee-cs merged 2 commits into
data-integrations:release/1.7from
Ashutosh-Jarvis:cherrypick-fix-indexoutofbound-exception

Conversation

@Ashutosh-Jarvis

@Ashutosh-Jarvis Ashutosh-Jarvis commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

… query returns empty results

Surface HTTP status and readable error message for non-JSON Salesforce OAuth responses

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Sunish-Dahiya left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please make the PR description better, add test reports and ensure all e2e tests are passing

@Ashutosh-Jarvis Ashutosh-Jarvis changed the title [Cherrypick] fix indexoutofbound exception [Cherrypick] Fix IndexOutOfBoundsException in SalesforceWideRecordReader and Handled HTML based error response Oct 30, 2026
@vikasrathee-cs
vikasrathee-cs merged commit 043b994 into data-integrations:release/1.7 Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants