fix: do not raise exception on 3xx responses in parse_response#173
Merged
Conversation
…#155) Change the error boundary from >= 300 to >= 400 so that 3xx responses (e.g. 302 returned by getReportFile) are treated as successful and not raised as CheckoutApiException. Add RSpec tests covering 302 redirect responses to prevent regression.
|
david-ruiz-cko
approved these changes
May 26, 2026
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.



What
parse_responsewas raisingCheckoutApiExceptionfor any status code>= 300, incorrectly treating 3xx redirect responses as errors. TheGET /reports/{reportId}/files/{fileId}endpoint returns302 Foundwith aLocationheader, which was being raised as an exception.Changes
lib/checkout_sdk/api_client.rb— change error boundary from>= 300to>= 400so 3xx responses are treated as successfulspec/checkout_sdk/api_client_spec.rb— add two tests covering 302 redirect: one asserting no exception is raised, one assertinghttp_metadata.status_codeis preservedRoot cause
The condition
response.status >= 300was too broad. 3xx responses are valid success responses for certain endpoints (e.g. report file downloads). Fix proposed in the original issue: change toresponse.status >= 400.Closes #155
Testing