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

Ruby Client: Setting :symbolize_keys on MultiJson breaks Client#buckets and Bucket#keys #135 [JIRA: CLIENTS-784] #135

Closed
danpisarski opened this Issue Dec 12, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@danpisarski

danpisarski commented Dec 12, 2013

I am using riak-client 1.4.2 with the Excon http_backend.

When I do Bucket#keys in irb, I get the complete list along with the expected warning.

But when I put similar code in a short script, and execute that script at the command line, I get:

/Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client/http_backend.rb:201:in `list_keys': undefined method `map' for nil:NilClass (NoMethodError)
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client.rb:352:in `block in list_keys'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client.rb:470:in `block in recover_from'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/innertube-1.0.2/lib/innertube.rb:127:in `take'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client.rb:468:in `recover_from'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client.rb:321:in `http'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client.rb:138:in `backend'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/client.rb:351:in `list_keys'
    from /Users/dan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/riak-client-1.4.2/lib/riak/bucket.rb:45:in `keys'

This is when using Bucket#keys with no block, or when trying to pass it a block to let it stream the processing.

I get the above error if using for instance: keys.each

But if I pass a block, the block never seems to actually be called (code in the block seems to not run, nor does a simple puts). Here is a quick example:

  tmp_client = Riak::Client.new(:http_backend => :Excon)
  bucket = tmp_client['some_bucket']

  bucket.keys do |key_array|
    puts key_array.inspect
  end

Again, same code run in irb works as expected.

Is it not possible to use #keys from actual code vs irb? If not, is there any recommended way to discover all they keys in a bucket from code, without foreknowledge of the keys?

@danpisarski

This comment has been minimized.

Show comment
Hide comment
@danpisarski

danpisarski Jan 6, 2014

Was able to narrow this down more - the problem occurs because of:

 MultiJson.load_options = {:symbolize_keys=>true}

Which, I had set in my application (and thus in the examples where I was trying to run some of the sample code above via a command line), but never set when testing these same steps in irb (and thus the difference of it seeming to work in irb and not in script).

The problem then looks to be in http_backend.rb where it specifically looks for ['buckets'] and doesn't take into account the possibility of [:buckets].

danpisarski commented Jan 6, 2014

Was able to narrow this down more - the problem occurs because of:

 MultiJson.load_options = {:symbolize_keys=>true}

Which, I had set in my application (and thus in the examples where I was trying to run some of the sample code above via a command line), but never set when testing these same steps in irb (and thus the difference of it seeming to work in irb and not in script).

The problem then looks to be in http_backend.rb where it specifically looks for ['buckets'] and doesn't take into account the possibility of [:buckets].

@danpisarski

This comment has been minimized.

Show comment
Hide comment
@danpisarski

danpisarski Jan 8, 2014

Made the title clearer

danpisarski commented Jan 8, 2014

Made the title clearer

@lukebakken lukebakken added this to the riak-ruby-client-2.4.0 milestone Feb 28, 2016

@lukebakken lukebakken self-assigned this Feb 28, 2016

@lukebakken lukebakken added the bug label Feb 28, 2016

@Basho-JIRA Basho-JIRA changed the title from Setting :symbolize_keys on MultiJson breaks Client#buckets and Bucket#keys to Ruby Client: Setting :symbolize_keys on MultiJson breaks Client#buckets and Bucket#keys #135 [JIRA: CLIENTS-784] Feb 29, 2016

@lukebakken

This comment has been minimized.

Show comment
Hide comment
@lukebakken

lukebakken Jun 8, 2016

Contributor

@danpisarski - HTTP has been deprecated in the Ruby client since the 2.0 release of the client. I'm going to close this but if a patch release with this fix is absolutely necessary, and you can't upgrade to the newest Ruby client (thus using TCP/protocol buffers), please re-open this issue and let me know about it.

Contributor

lukebakken commented Jun 8, 2016

@danpisarski - HTTP has been deprecated in the Ruby client since the 2.0 release of the client. I'm going to close this but if a patch release with this fix is absolutely necessary, and you can't upgrade to the newest Ruby client (thus using TCP/protocol buffers), please re-open this issue and let me know about it.

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