puppetlabs/puppet · error · ArgumentError

expected a hash with type to format mappings, got instance o

Error message

expected a hash with type to format mappings, got instance of '#{fmt.class}'

What it means

Error "expected a hash with type to format mappings, got instance of '#{fmt.class}'" thrown in puppetlabs/puppet.

Source

Thrown at lib/puppet/pops/types/string_converter.rb:539

  #  # A method only used for manual debugging as the default output of the formatting rules is
  #  # very hard to read otherwise.
  #  #
  #  # @api private
  #  def dump_string_formats(f, indent = 1)
  #     return f.to_s unless f.is_a?(Hash)
  #     "{#{f.map {|k,v| "#{k.to_s} => #{dump_string_formats(v,indent+1)}"}.join(",\n#{'  '*indent}  ")}}"
  #  end

  def _convert(val_type, value, format_map, indentation)
    @string_visitor.visit_this_3(self, val_type, value, format_map, indentation)
  end
  private :_convert

  def validate_input(fmt)
    return nil if fmt.nil?
    unless fmt.is_a?(Hash)
      raise ArgumentError, "expected a hash with type to format mappings, got instance of '#{fmt.class}'"
    end

    fmt.each_with_object({}) do |entry, result|
      key, value = entry
      unless key.is_a?(Types::PAnyType)
        raise ArgumentError, "top level keys in the format hash must be data types, got instance of '#{key.class}'"
      end

      if value.is_a?(Hash)
        result[key] = validate_container_input(value)
      else
        result[key] = Format.new(value)
      end
    end
  end
  private :validate_input

  FMT_KEYS = %w[separator separator2 format string_formats].freeze

View on GitHub (pinned to e227c27540)

When it happens

Trigger: Thrown at lib/puppet/pops/types/string_converter.rb:539 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/db2876735d830eb7. Report an issue: GitHub.