-
Notifications
You must be signed in to change notification settings - Fork 463
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
Occasional invalid JSON returned by Stripe #830
Comments
@candrewsmtn Thank you for the report! In theory, our API should always return a JSON string for the error which is why the library expects this explicitly. In some really rare cases, it's possible for the request to fail in a way that a non-json error is returned. That error is unlikely to be helpful since it would certainly be some default HTML page error or similar or a truncated response but I do agree that logging it could be useful. Tagging as future for @brandur-stripe to maybe investigate. |
That error message originates directly from Go core, but yeah, we should do a better job of at least logging more detail about the problem. I'll write a patch for that. |
It would be good if the error message was replaced with something more useful. Just an indication of the HTTP status code and the fact it could not be parsed would help enormously to work out if the issue is with us, stripe, or the network in between. |
As mentioned in #830, we occasionally have a situation where non-JSON data comes back to a client even though this is not supposed to happen. Unfortunately, when it does, the error message produced by Go isn't very good and doesn't help much with debugging. Here we add a new helper function for unmarshaling JSON in standard or error responses that behaves normally in the normal cases, and in case of a failure, adds more context to the standard library's error and logs.
As mentioned in #830, we occasionally have a situation where non-JSON data comes back to a client even though this is not supposed to happen. Unfortunately, when it does, the error message produced by Go isn't very good and doesn't help much with debugging. Here we add a new helper function for unmarshaling JSON in standard or error responses that behaves normally in the normal cases, and in case of a failure, adds more context to the standard library's error and logs.
We just released 60.4.0, which logs some more flavor in case of a failure like this. @candrewsmtn Would you mind trying that and checking back in if you discover something concerning is revealed? |
Sure, will do
…On Mon, 15 Apr 2019, 22:01 Brandur, ***@***.***> wrote:
We just released 60.4.0, which logs some more flavor in case of a failure
like this.
@candrewsmtn <https://github.com/candrewsmtn> Would you mind trying that
and checking back in if you discover something concerning is revealed?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#830 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aq2ixWa6Pejm8nvYz_UYAXdBQZDXnut0ks5vhOimgaJpZM4cqzmu>
.
|
Hi Everybody attempt to get customer resulted in Stripe error:
happened only once so far, cannot reproduce. stripe-go: 60.13.1 |
Bumps [sorbet](https://github.com/sorbet/sorbet) from 0.5.10455 to 0.5.10477. - [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]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Very occasionally (once every few hundred thousands requests) I will receive an apparently nonsensical error from
charge.New()
. Errors such as:and
After a bit of head-scratching I realised that these are actually JSON unmarshaling errors so I had a look in
stripe.go
and found this at line 437:and in ResponseToError at line 451:
The problem here is that invalid JSON is being returned from the remote API but the client code is making no effort at exposing it. And if the response is a 400 or worse, it doesn't even log the actual body to the debug log.
It would be useful to be able to get the actual raw response from the request so it can be logged and we can understand why we're seeing failures, rather than just cryptic notes about unexpected vowels.
The text was updated successfully, but these errors were encountered: