omise-ruby
omise-ruby copied to clipboard
Could you use JSON.parse instead of JSON.load?
Expected behavior
JSON.parse usage (bad template; there is no place to provide a proper explanation. will comment later)
Actual behavior
JSON.load usage (bad template; there is no place to provide a proper explanation. will comment later)
Steps to reproduce the issue
Simply using the library
Logs
No response
Screenshots
No response
Name and version information
SDK: omise (0.11.0) Package Manager: bundler Operating System: Linux
You see the JSON usage here https://github.com/omise/omise-ruby/blob/a0efda8b226c92943eb4541446e19aeb1c55194a/lib/omise/util.rb#L20
Typically, JSON.load and JSON.parse are somewhat interchangeable.
But they differ under some circumstances. And that circumstance just happened today.
MultiJSON, used in Rails projects, allows configuring different JSON parsers. I use Oj in my projects via Oj.optimize_rails.
The issue is, with such configuration, JSON.load will raise Oj::ParseError while JSON.parse will raise JSON::ParserError.
And that parse error will occur when there are faults in Omise's responses.
Today, the new backend deployed by Opn is at fault for returning malformed JSON, which made me notice the error.
Could you change JSON.load here to JSON.parse?
@midnight-wonderer Thanks for reaching out. We will look into this and let you know about our findings. We will need more details about the issue. Can you please shed more light on the faults in Omise's responses?
Disscussed with the support in ticket no. 646321
@midnight-wonderer We are closing this issue as our support team confirmed it has already been resolved. Thank you.
@aashishgurung That is that, and this is this.
The internal server error isn't there anymore. But the client software is still broken. I can't rescue the error properly. Should I send a pull request?
@midnight-wonderer Thank you for submitting the PR. We'll review and test the changes, and proceed accordingly.