ruby/ruby · error · ArgumentError

expected Array of or Hash of components of #{self} (#{compon

Error message

expected Array of or Hash of components of #{self} (#{component.join(', ')})

What it means

Error "expected Array of or Hash of components of #{self} (#{component.join(', ')})" thrown in ruby/ruby.

Source

Thrown at lib/uri/generic.rb:130

    # with check.  Components are: scheme, userinfo, host, port, registry, path,
    # opaque, query, and fragment. You can provide arguments either by an Array or a Hash.
    # See ::new for hash keys to use or for order of array items.
    #
    def self.build(args)
      if args.kind_of?(Array) &&
          args.size == ::URI::Generic::COMPONENT.size
        tmp = args.dup
      elsif args.kind_of?(Hash)
        tmp = ::URI::Generic::COMPONENT.collect do |c|
          if args.include?(c)
            args[c]
          else
            nil
          end
        end
      else
        component = self.component rescue ::URI::Generic::COMPONENT
        raise ArgumentError,
              "expected Array of or Hash of components of #{self} (#{component.join(', ')})"
      end

      tmp << nil
      tmp << true
      return self.new(*tmp)
    end

    #
    # == Args
    #
    # +scheme+::
    #   Protocol scheme, i.e. 'http','ftp','mailto' and so on.
    # +userinfo+::
    #   User name and password, i.e. 'sdmitry:bla'.
    # +host+::
    #   Server host name.
    # +port+::

View on GitHub (pinned to 0e5b888e1c)

When it happens

Trigger: Thrown at lib/uri/generic.rb:130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruby/ruby@0e5b888e1c (2026-08-21). Data as JSON: /api/errors/24eaa5da086fa063. Report an issue: GitHub.