puppetlabs/puppet · error · ArgumentError

string conversion expects a Default value or a Hash of type

Error message

string conversion expects a Default value or a Hash of type to format mappings, got a '#{string_formats.class}'

What it means

Error "string conversion expects a Default value or a Hash of type to format mappings, got a '#{string_formats.class}'" thrown in puppetlabs/puppet.

Source

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

        # add the format given for the exact type
        string_formats = { Puppet::Pops::Types::PHashType::DEFAULT => { 'format' => string_formats } }
      else
        # add the format given for the exact type
        string_formats = { value_type => string_formats }
      end
    end

    case string_formats
    when :default
    # do nothing, use default formats

    when Hash
      # Convert and validate user input
      string_formats = validate_input(string_formats)
      # Merge user given with defaults such that user options wins, merge is deep and format specific
      options = Format.merge_string_formats(DEFAULT_STRING_FORMATS, string_formats)
    else
      raise ArgumentError, "string conversion expects a Default value or a Hash of type to format mappings, got a '#{string_formats.class}'"
    end

    _convert(value_type, value, options, DEFAULT_INDENTATION)
  end

  #  # 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

View on GitHub (pinned to e227c27540)

When it happens

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