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

"init_converters" method receives an extra parameter in Ruby 2.5.3 #220

Closed
j3pic opened this issue Nov 14, 2018 · 1 comment · Fixed by instacart/csvlint.rb#1
Closed

Comments

@j3pic
Copy link

j3pic commented Nov 14, 2018

Expected Behaviour

What should happen?

When Csvlint is loaded into Ruby 2.5.3, it should validate valid CSV files, just like
it does in older versions of Ruby.

Current Behaviour (for problems)

What currently happens that isn't expected behaviour?

Csvlint reports :invalid_encoding for all lines. It turns out this is because it is assumed that the only reason an ArgumentError will be thrown is if there's invalid encoding.

When I commented out the rescue statements, I got this backtrace:

    Exception: ArgumentError: wrong number of arguments (given 3, expected 1..2)
    --
     0: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:43:in `init_converters'
     1: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/2.5.0/csv.rb:1554:in `initialize'
     2: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/2.5.0/csv.rb:1331:in `new'
     3: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/2.5.0/csv.rb:1331:in `parse_line'
     4: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:214:in `parse_contents'
     5: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:198:in `validate_line'
     6: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:178:in `parse_line'
     7: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:148:in `block in parse_batch'
     8: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:146:in `each'
     9: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:146:in `parse_batch'
    10: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:116:in `block in validate_stream'
    11: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/io.rb:29:in `each_in_batches'
    12: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:114:in `validate_stream'
    13: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:107:in `validate'
    14: /home/j3pic/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/csvlint.rb-2b23970b9997/lib/csvlint/validate.rb:88:in `initialize'
    15: (pry):7:in `new'
    16: (pry):7:in `block in lint_file'

Here's how init_converters is being called by Ruby:

    init_converters(converters, :@converters, :convert)
    init_converters(header_converters, :@header_converters, :header_convert)

Csvlint's implementation of init_converters only accepts 2 parameters:
https://github.com/theodi/csvlint.rb/blob/master/lib/csvlint/validate.rb#L43

Steps to Reproduce (for problems)

Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant

  1. Upgrade to Ruby 2.5.3
  2. Evaluate this:
File.open "/some/file.csv" do |f|
  new_linter = Csvlint::Validator.new(f,
                                      {"header"=>true, "skipInitialSpace"=>true, "delimiter"=>",", 
                                       "quoteChar"=>"\""}, nil, {:batch_size=>1000,
                                                                 :allow_quoted_linebreaks=>false})
end

Your Environment

Include as many relevant details about the environment you experienced the bug in - this will help us resolve the bug more expediently

  • Environment name and version (e.g. Chrome 39, node.js 5.4):
    Ruby 2.5.3p105
@j3pic
Copy link
Author

j3pic commented Nov 15, 2018

Looks like this is fixed by #217

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