puppetlabs/puppet · error · ArgumentError
top level keys in the format hash must be data types, got in
Error message
top level keys in the format hash must be data types, got instance of '#{key.class}' What it means
Error "top level keys in the format hash must be data types, got instance of '#{key.class}'" thrown in puppetlabs/puppet.
Source
Thrown at lib/puppet/pops/types/string_converter.rb:545
# 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
def validate_container_input(fmt)
if (fmt.keys - FMT_KEYS).size > 0
raise ArgumentError, "only #{FMT_KEYS.map { |k| "'#{k}'" }.join(', ')} are allowed in a container format, got #{fmt}"
end
View on GitHub (pinned to e227c27540)
When it happens
Trigger: Thrown at lib/puppet/pops/types/string_converter.rb:545 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/b51636ce26db6f75.
Report an issue: GitHub.