Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Handle HTTP 400 HTML contained response as empty JSON #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kjubichan
Copy link

On production server in one of our product we periodically see the error with trace:

Message:
757: unexpected token at '<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" class="no-js lt-ie9 lt-ie8 lt-ie7 not-logged-in "> <![endif]-->
<!--[if IE 7]>         <html lang="en" class="no-js lt-ie9 lt-ie8 not-logged-in "> <![endif]-->
<!--[if I

Exception Class:
JSON::ParserError

/usr/local/lib/ruby/2.1.0/json/common.rb:155:in `parse'
/usr/local/lib/ruby/2.1.0/json/common.rb:155:in `parse'
/ruby/2.1.0/gems/instagram-1.1.3/lib/faraday/raise_http_exception.rb:43:in `error_body'
/ruby/2.1.0/gems/instagram-1.1.3/lib/faraday/raise_http_exception.rb:36:in `error_message_400'
/ruby/2.1.0/gems/instagram-1.1.3/lib/faraday/raise_http_exception.rb:13:in `block in call'
/ruby/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:57:in `on_complete'
/ruby/2.1.0/gems/instagram-1.1.3/lib/faraday/raise_http_exception.rb:8:in `call'
/ruby/2.1.0/gems/faraday_middleware-0.9.1/lib/faraday_middleware/response_middleware.rb:30:in `call'
/ruby/2.1.0/gems/faraday-0.9.1/lib/faraday/response.rb:8:in `call'
/ruby/2.1.0/gems/faraday-0.9.1/lib/faraday/request/url_encoded.rb:15:in `call'
/ruby/2.1.0/gems/instagram-1.1.3/lib/faraday/oauth2.rb:33:in `call'
/ruby/2.1.0/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
/ruby/2.1.0/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
/ruby/2.1.0/gems/faraday-0.9.1/lib/faraday/connection.rb:140:in `get'
/ruby/2.1.0/gems/instagram-1.1.3/lib/instagram/request.rb:31:in `request'

I think it is quite reasonable to handle unexpected HTML response as empty JSON.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@chriso0710
Copy link

Good job, just wanted to say thanks @kjubichan.
That fix is really essential, should be merged soon into master branch IMHO...

@ghost ghost added the CLA Signed label Jul 12, 2016
@AdamDenoon
Copy link

Please merge this into Master!

@chriso0710
Copy link

My comment is 2 years old. As this repo "is not actively maintained" by instagram/facebook, I very much doubt that any bugfixes will get merged.
I think it would be better to use a fork...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants