puppetlabs/puppet · error · ArgumentError

Only Array, Hash, and Object types can be used as container

Error message

Only Array, Hash, and Object types can be used as container types. Got %{type}

What it means

Error "Only Array, Hash, and Object types can be used as container types. Got %{type}" thrown in puppetlabs/puppet.

Source

Thrown at lib/puppet/pops/types/tree_iterators.rb:39

  # @param [Hash] options the options
  # @option options [PTypeType] :container_type ('Variant[Hash, Array, Object]') The type(s) that should be treated as containers. The
  #   given type(s) must be assignable to the default container_type.
  # @option options [Boolean] :include_root ('true') If the root container itself should be included in the iteration (requires
  #   `include_containers` to also be `true` to take effect).
  # @option options [Boolean] :include_containers ('true') If containers should be included in the iteration
  # @option options [Boolean] :include_values ('true') If non containers (values) should be included in the iteration
  # @option options [Boolean] :include_refs ('false') If (non containment) referenced values in Objects should be included
  #
  def initialize(enum, options = EMPTY_HASH)
    @root = enum
    @element_t = nil
    @value_stack = [enum]
    @indexer_stack = []
    @current_path = []
    @recursed = false
    @containers_t = options['container_type'] || DEFAULT_CONTAINERS
    unless DEFAULT_CONTAINERS.assignable?(@containers_t)
      raise ArgumentError, _("Only Array, Hash, and Object types can be used as container types. Got %{type}") % { type: @containers_t }
    end

    @with_root       = extract_option(options, 'include_root', true)
    @with_containers = extract_option(options, 'include_containers', true)
    @with_values     = extract_option(options, 'include_values', true)
    @with_root       = @with_containers && extract_option(options, 'include_root', true)
    unless @with_containers || @with_values
      raise ArgumentError, _("Options 'include_containers' and 'include_values' cannot both be false")
    end

    @include_refs = !!options['include_refs']
  end

  # Yields each `path, value` if the block arity is 2, and only `value` if arity is 1
  #
  def each(&block)
    loop do
      if block.arity == 1

View on GitHub (pinned to e227c27540)

When it happens

Trigger: Thrown at lib/puppet/pops/types/tree_iterators.rb:39 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/ca2f711e3b2a0e48. Report an issue: GitHub.