Skip to content
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

A JSON text must at least contain two octets! #101

Open
ddavtian opened this issue Aug 1, 2013 · 6 comments
Open

A JSON text must at least contain two octets! #101

ddavtian opened this issue Aug 1, 2013 · 6 comments

Comments

@ddavtian
Copy link

ddavtian commented Aug 1, 2013

I think this might be an issue in the JSON parser?

    [2013-07-31T21:32:05.718626 #9653]  WARN -- : Retrying Parse Error #<JSON::ParserError: A JSON text must at least contain two octets!> on request /1/users nil response #<Patron::Response @status_line='HTTP/1.1 502 BAD_GATEWAY'>

/Users/ddavtian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/json/common.rb:155:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
from /Users/ddavtian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/json/common.rb:155:in `new'
from /Users/ddavtian/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/json/common.rb:155:in `parse'
from /Users/ddavtian/.rvm/gems/ruby-2.0.0-p0/gems/parse-ruby-client-0.1.15/lib/parse/client.rb:102:in `request'
from /Users/ddavtian/.rvm/gems/ruby-2.0.0-p0/gems/parse-ruby-client-0.1.15/lib/parse/query.rb:127:in `get'
from new_facebook_user_notify.rb:56:in `compareFacebookFriendsToParse'
from new_facebook_user_notify.rb:99:in `<main>'
@ericcj
Copy link
Contributor

ericcj commented Aug 15, 2013

this is a server error from parse as per the 502 response code. it was retried so hopefully it succeeded? in any case this isn't a client bug

@henrik
Copy link
Contributor

henrik commented Jan 2, 2014

"A JSON text must at least contain two octets!" is tech talk for "The JSON library got an empty string but expected some JSON, at the very least an {}".

It might be helpful if the client would encapsulate this and instead raise an error something like Parse::ServerError.

@adelevie
Copy link
Owner

adelevie commented Jan 2, 2014

I'm fine with this. Wanna send a PR?

@ericcj
Copy link
Contributor

ericcj commented Jan 2, 2014

this one is actually logging of a retry, but it would be indeed be re-raised as JSON::ParserError if retries were exhausted. it would probably be preferable to encapsulate all server errors (5xx, timeout, patron, whatever) under Parse::ServerError as long as it captured the cause

@henrik
Copy link
Contributor

henrik commented Jan 2, 2014

I'm afraid I don't have the time to make a pull request at the moment. Possibly later, if we do a "handle Parse errors gracefully" sprint.

@rails-webmaster
Copy link

Hello,

I have the same issue as you had.
Here is the code base I am running on.

params = {:first_name => "John", :last_name => "Smith"}

uri = URI.parse(make_uri("person/" + id.to_s))
Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|

request = Net::HTTP::Patch.new(uri.request_uri)
request.add_field('Content-Type', 'application/json')
request.body = JSON.dump(params)

@response = http.request request # Net::HTTPResponse object

end

JSON.parse @response.body

I hope you would like to help me with any solution.

Best regards,

John

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

No branches or pull requests

6 participants