puppetlabs/puppet · error · ArgumentError

Can only append Array or Hash to a Hash

Error message

Can only append Array or Hash to a Hash

What it means

Error "Can only append Array or Hash to a Hash" thrown in puppetlabs/puppet.

Source

Thrown at lib/puppet/pops/evaluator/evaluator_impl.rb:1235

      x + y # new array with concatenation
    when Hash
      y = case y
          when Hash then y
          when Array
            # Hash[[a, 1, b, 2]] => {}
            # Hash[a,1,b,2] => {a => 1, b => 2}
            # Hash[[a,1], [b,2]] => {[a,1] => [b,2]}
            # Hash[[[a,1], [b,2]]] => {a => 1, b => 2}
            # Use type calculator to determine if array is Array[Array[?]], and if so use second form
            # of call
            t = @@type_calculator.infer(y)
            if t.element_type.is_a? Types::PArrayType
              y.to_h
            else
              Hash[*y]
            end
          else
            raise ArgumentError, _('Can only append Array or Hash to a Hash')
          end
      x.merge y # new hash with overwrite
    when URI
      raise ArgumentError, _('An URI can only be merged with an URI or String') unless y.is_a?(String) || y.is_a?(URI)

      x + y
    when Types::PBinaryType::Binary
      raise ArgumentError, _('Can only append Binary to a Binary') unless y.is_a?(Types::PBinaryType::Binary)

      Types::PBinaryType::Binary.from_binary_string(x.binary_buffer + y.binary_buffer)
    else
      concatenate([x], y)
    end
  end

  # Produces the result x \ y (set difference)
  # When `x` is an Array, `y` is transformed to an array and then all matching elements removed from x.
  # When `x` is a Hash, all contained keys are removed from x as listed in `y` if it is an Array, or all its keys if it is a Hash.

View on GitHub (pinned to e227c27540)

When it happens

Trigger: Thrown at lib/puppet/pops/evaluator/evaluator_impl.rb:1235 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/6ce03b866619311a. Report an issue: GitHub.