Repository navigation
Conversation
Refactor body assignment to handle None and non-string cases.
|
Thanks for the contribution! Before we can merge this, we need @jeromeyyy to sign the Salesforce Inc. Contributor License Agreement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #57.
BaseRequest.requestinSalesforcePy/commons.pyunconditionally parses every response body withresponse.json(). The Bulk API 2.0 job results endpoints (successfulResults,failedResults,unprocessedrecords) returntext/csv, so the JSON parse raises, the exception is swallowed by theexcept/finally, and callers always getNone. This matches the symptom reported in #57; I reproduced it locally with a mockedtext/csvresponse (no live-org testing).Change
Parse the response by its
Content-Type:None(unchanged from current behavior, e.g. batch upload 201 responses)response.json()exactly as before, so no other endpoint or content type changes behaviorThe binary/blob path is unaffected:
SObjectBloboverridesrequest()and handles the streamed response itself.Tests
The test harness in
tests/testutil.pyJSON-encoded string fixture bodies before serving them, so the mocked CSV endpoints were served as JSON string literals and the existing tests could not reproduce the real API behavior. The harness now serves string bodies verbatim. With that correction, the existingtest_get_successful_jobs,test_get_failed_jobsandtest_get_unprocessed_jobsfail against the original code (they returnNone) and pass with this fix. Two blob assertions intests/test_sobjects.pythat expected the double-encoded content were updated; they pass on both original and fixed code.Full test suite: 79 passed.
Happy to adjust if you would prefer a different return type for the CSV endpoints.