-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use FaradayStripeEncoder
to encode all parameter styles
#741
Merged
Conversation
This file contains 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
brandur-stripe
force-pushed
the
brandur-simpler-encoding
branch
from
February 1, 2019 22:26
1aaf9a9
to
83fb001
Compare
ob-stripe
approved these changes
Feb 2, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
test/stripe/stripe_client_test.rb
Outdated
@@ -794,6 +794,16 @@ class StripeClientTest < Test::Unit::TestCase | |||
assert(!trace_payload["last_request_metrics"]["request_duration_ms"].nil?) | |||
end | |||
end | |||
|
|||
context "FaradayStripeEncoder" do | |||
should "replace Faraday::UploadIO instances in parametes" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small typo here:
Suggested change
should "replace Faraday::UploadIO instances in parametes" do | |
should "replace Faraday::UploadIO instances in parameters" do |
Makes a few tweaks to hopefully simplify clarity things: * `FaradayStripeEncoder` now becomes the way to encode all of form, multipart form, and query parameters. * Introduce a cache in it so that we don't have to encode everything twice (once for logging, and once for the request body). * Try to sanitize logging a bit by replacing `Faraday::UploadIO`s found in incoming parameters with a string representation of the file (note that all other styles of file input like `File` or `Tempfile` have been converted to `Faraday::UploadIO` by the time they reach the encoder).
brandur-stripe
force-pushed
the
brandur-simpler-encoding
branch
from
February 3, 2019 20:25
83fb001
to
9dd5bdb
Compare
Thanks OB, and nice catch on that typo! |
Released as 4.8.0. |
brandur-stripe
pushed a commit
that referenced
this pull request
Feb 11, 2019
In #741 I tried to do something too clever by replacing instances of `Faraday::UploadIO` found in parameters with a human-readable string to improve `STRIPE_LOG` logging output. I thought I'd tested it at the time, but apparently not (or not well enough), and this change caused the regression detailed in #742. My findings about how Faraday encodes multipart were apparently wrong and it does use these parameters, so here we remove the step where we try to nicen them for logging. The logs look a little worse, but it's not that big of a deal. I've tested this patch against the API and confirmed that it addresses the problem. Fixes #742.
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.
Makes a few tweaks to hopefully simplify clarity things:
FaradayStripeEncoder
now becomes the way to encode all of form,multipart form, and query parameters.
twice (once for logging, and once for the request body).
Faraday::UploadIO
s foundin incoming parameters with a string representation of the file (note
that all other styles of file input like
File
orTempfile
havebeen converted to
Faraday::UploadIO
by the time they reach theencoder).
r? @ob-stripe