MultiJson::DecodeError on 401 response #80

Closed
mdub opened this Issue Nov 4, 2011 · 2 comments

Comments

Projects
None yet
3 participants
@mdub

mdub commented Nov 4, 2011

Occasionally, my app seems to be receiving unexpected 401 error responses from the LinkedIn API, confusing the error-handling in the linked in gem. More specifically, the API appears to be returning an HTML payload, but the gem expects JSON.

MultiJson::DecodeError: 743: unexpected token at '<html><head><title>Apache Tomcat/6.0.32 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>This request requires HTTP authentication ().</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.32</h3></body></html>'

Here's the corresponding backtrace:

.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/json-1.6.0/lib/json/common.rb:148:in `parse'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:13:in `decode'
.bundle/gems/ruby/1.9.1/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/mash.rb:9:in `from_json'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:45:in `raise_errors'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/helpers/request.rb:16:in `get'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:32:in `simple_query'
.bundle/gems/ruby/1.9.1/gems/linkedin-0.3.2/lib/linked_in/api/query_methods.rb:8:in `profile'
[PROJECT_ROOT]models/linked_in_profile.rb:14:in `find'

I think the gem needs to be more resilient in the face of this type of error.

@alainravet

This comment has been minimized.

Show comment Hide comment
@alainravet

alainravet Jul 5, 2012

This problem still happens.
Credentials errors in the API can materialize in the gem as either
LinkedIn::Errors::UnauthorizedError or
MultiJson::DecodeError

This problem still happens.
Credentials errors in the API can materialize in the gem as either
LinkedIn::Errors::UnauthorizedError or
MultiJson::DecodeError

@hexgnu

This comment has been minimized.

Show comment Hide comment
@hexgnu

hexgnu Apr 27, 2013

Owner

Will investigate.

Owner

hexgnu commented Apr 27, 2013

Will investigate.

@hexgnu hexgnu closed this Nov 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment