{"record":{"id":"b51636ce26db6f75","repo":"puppetlabs/puppet","slug":"top-level-keys-in-the-format-hash-must-be-data-typ","errorCode":null,"errorMessage":"top level keys in the format hash must be data types, got instance of '#{key.class}'","messagePattern":"top level keys in the format hash must be data types, got instance of '#(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":545,"sourceCode":"  #     return f.to_s unless f.is_a?(Hash)\n  #     \"{#{f.map {|k,v| \"#{k.to_s} => #{dump_string_formats(v,indent+1)}\"}.join(\",\\n#{'  '*indent}  \")}}\"\n  #  end\n\n  def _convert(val_type, value, format_map, indentation)\n    @string_visitor.visit_this_3(self, val_type, value, format_map, indentation)\n  end\n  private :_convert\n\n  def validate_input(fmt)\n    return nil if fmt.nil?\n    unless fmt.is_a?(Hash)\n      raise ArgumentError, \"expected a hash with type to format mappings, got instance of '#{fmt.class}'\"\n    end\n\n    fmt.each_with_object({}) do |entry, result|\n      key, value = entry\n      unless key.is_a?(Types::PAnyType)\n        raise ArgumentError, \"top level keys in the format hash must be data types, got instance of '#{key.class}'\"\n      end\n\n      if value.is_a?(Hash)\n        result[key] = validate_container_input(value)\n      else\n        result[key] = Format.new(value)\n      end\n    end\n  end\n  private :validate_input\n\n  FMT_KEYS = %w[separator separator2 format string_formats].freeze\n\n  def validate_container_input(fmt)\n    if (fmt.keys - FMT_KEYS).size > 0\n      raise ArgumentError, \"only #{FMT_KEYS.map { |k| \"'#{k}'\" }.join(', ')} are allowed in a container format, got #{fmt}\"\n    end\n","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L527-L563","documentation":"Error \"top level keys in the format hash must be data types, got instance of '#{key.class}'\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/pops/types/string_converter.rb:545 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}