-
Notifications
You must be signed in to change notification settings - Fork 460
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
Fix encoding of list params for bank accounts and cards #633
Conversation
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.
Damn, I never assumed that change could have broken the API that way. Thanks for figuring it out.
Added 2 comments about the test suite
card_test.go
Outdated
|
||
// Adds `object` for customer (this will hit the sources endpoint) | ||
{ | ||
params := &CardListParams{Account: String("acct_123")} |
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.
This should be Customer: String("cus_123")
instead
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.
Oops! Thank you. Fixed.
form.AppendTo(body, params) | ||
t.Logf("body = %+v", body) | ||
assert.Equal(t, []string{"bank_account"}, body.Get("object")) | ||
} |
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.
should you be testing Account and Customer like you do for cards?
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.
Yeah, I skipped it because the same conditional branch just adds object
regardless of the circumstances, but I guess it can't hurt to be explicit. Broke it into two test cases like cards.
Fixes a bug discovered in #632 whereby because we were manually adding a filter like `?object=bank_account` to the end of paths, we'd clash with the `form` package's attempt at an encoding if both came into play. This would have the effect of producing an invalid URL like this: ``` /accounts/acc_xxxxxx/external_accounts?object=bank_account?limit=1&starting_after=ba_xxxxxx ``` (Note the multiple `?`s in the query string.) Here we stop manually adding filters to URL paths and move them into a custom `AppendTo` override for the `form` package. Bank accounts and cards were the only places that we were doing this, so only they were affected. We also add tests to make sure that we're doing the right thing.
8420692
to
d90d28b
Compare
Bumps [sorbet](https://github.com/sorbet/sorbet) from 0.5.10274 to 0.5.10286. - [Release notes](https://github.com/sorbet/sorbet/releases) - [Commits](https://github.com/sorbet/sorbet/commits) --- updated-dependencies: - dependency-name: sorbet dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fixes a bug discovered in #632 whereby because we were manually adding a
filter like
?object=bank_account
to the end of paths, we'd clash withthe
form
package's attempt at an encoding if both came into play. Thiswould have the effect of producing an invalid URL like this:
(Note the multiple
?
s in the query string.)Here we stop manually adding filters to URL paths and move them into a
custom
AppendTo
override for theform
package. Bank accounts andcards were the only places that we were doing this, so only they were
affected.
We also add tests to make sure that we're doing the right thing.
Fixes #632.
r? @remi-stripe
cc @stripe/api-libraries