Project

General

Profile

Actions

Bug #18509

closed

yajl.rb - (# TODO: this code smells, any ideas?) - "ArgumentError"

Added by dklein (Dmitri Klein) about 2 years ago. Updated about 2 years ago.

Status:
Third Party's Issue
Assignee:
-
Target version:
-
[ruby-core:107236]

Description

Please clarify - can we trust this code in yajl-ruby gem yajl.rb file?

class Encoder
def self.encode(obj, *args, &block)
# TODO: this code smells, any ideas?
args.flatten!
options = {}
io = nil
args.each do |arg|
if arg.is_a?(Hash)
options = arg
elsif arg.respond_to?(:write)
io = arg
end
end if args.any?
new(options).encode(obj, io, &block)
end
end
end

========= it generates following error:

2022-01-21 12:26:09 -0500 [warn]: fluent/root_agent.rb:187:emit_error_event: dump an error event: error_class=ArgumentError error="wrong number of arguments (1 for 0)" location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in initialize'" tag="fluent.warn" time=1642785969 record={"error_class"=>"ArgumentError", "error"=>"wrong number of arguments (1 for 0)", "location"=>"/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in initialize'", "tag"=>"fluent.debug", "time"=>1642785969, "record"=>{"message"=>"fluentd main process get SIGINT", "@timestamp"=>"2022-01-21T12:26:09-05:00"}, "message"=>"dump an error event: error_class=ArgumentError error="wrong number of arguments (1 for 0)" location="/opt/csw/lib/ruby/gems/2.0.0/gems/yajl-ruby-1.4.1/lib/yajl.rb:80:in `initialize'" tag="fluent.debug" time=1642785969 record={"message"=>"fluentd main process get SIGINT", "@timestamp"=>"2022-01-21T12:26:09-05:00"}", "@timestamp"=>"2022-01-21T12:26:09-05:00"}

Updated by jeremyevans0 (Jeremy Evans) about 2 years ago

  • Status changed from Open to Third Party's Issue

This code doesn't come from Ruby, it comes from ruby-yajl (an external project): https://github.com/brianmario/yajl-ruby . You should ask the ruby-yajl developers about this, since it is their code.

In the future, before you file additional bugs on Redmine, please check they are bugs in Ruby itself, and not in external gems. Now that most of the standard library has been gemified, even in the standard library, you should try to find the appropriate upstream repository and file the bug there.

Additionally, only file bugs for Ruby versions that are currently supported. The example you provided shows you are using Ruby 2.0, which went out of support almost 6 years ago.

Actions

Also available in: Atom PDF

Like0
Like0