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

Inaccurate proxy behavior when a hash with String and Symbol keys is passed #148

Closed
qnighy opened this issue Apr 13, 2021 · 0 comments · Fixed by #149
Closed

Inaccurate proxy behavior when a hash with String and Symbol keys is passed #148

qnighy opened this issue Apr 13, 2021 · 0 comments · Fixed by #149

Comments

@qnighy
Copy link
Contributor

qnighy commented Apr 13, 2021

The following code fails, starting from connection_pool 2.2.4 (#143).

require 'connection_pool'

class Logger
  def post(table, map)
    $stderr.puts "Wrote to #{table}: #{map.inspect}"
  end
end

logger = ConnectionPool::Wrapper.new { Logger.new }

logger.post('log', { user_id: 1, 'count' => 2 })

2.2.3:

$ ruby repro.rb
Wrote to log: {:user_id=>1, "count"=>2}

2.2.4 + Ruby 2.7:

$ ruby repro.rb
Traceback (most recent call last):
	9: from repro.rb:11:in `<main>'
	8: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool/wrapper.rb:37:in `method_missing'
	7: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool/wrapper.rb:14:in `with'
	6: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool.rb:59:in `with'
	5: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool.rb:59:in `handle_interrupt'
	4: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool.rb:62:in `block in with'
	3: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool.rb:62:in `handle_interrupt'
	2: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool.rb:63:in `block (2 levels) in with'
	1: from /Users/qnighy/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/connection_pool-2.2.4/lib/connection_pool/wrapper.rb:38:in `block in method_missing'
repro2.rb:4:in `post': unknown keyword: :user_id (ArgumentError)

I wish it were an edge case, but unfortunately we found it in our production code.

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

Successfully merging a pull request may close this issue.

1 participant