{"record":{"id":"4a386f26f2ee8b0a","repo":"puppetlabs/puppet","slug":"string-conversion-expects-a-default-value-or-a-has","errorCode":null,"errorMessage":"string conversion expects a Default value or a Hash of type to format mappings, got a '#{string_formats.class}'","messagePattern":"string conversion expects a Default value or a Hash of type to format mappings, got a '#(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pops/types/string_converter.rb","lineNumber":516,"sourceCode":"        # add the format given for the exact type\n        string_formats = { Puppet::Pops::Types::PHashType::DEFAULT => { 'format' => string_formats } }\n      else\n        # add the format given for the exact type\n        string_formats = { value_type => string_formats }\n      end\n    end\n\n    case string_formats\n    when :default\n    # do nothing, use default formats\n\n    when Hash\n      # Convert and validate user input\n      string_formats = validate_input(string_formats)\n      # Merge user given with defaults such that user options wins, merge is deep and format specific\n      options = Format.merge_string_formats(DEFAULT_STRING_FORMATS, string_formats)\n    else\n      raise ArgumentError, \"string conversion expects a Default value or a Hash of type to format mappings, got a '#{string_formats.class}'\"\n    end\n\n    _convert(value_type, value, options, DEFAULT_INDENTATION)\n  end\n\n  #  # A method only used for manual debugging as the default output of the formatting rules is\n  #  # very hard to read otherwise.\n  #  #\n  #  # @api private\n  #  def dump_string_formats(f, indent = 1)\n  #     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","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pops/types/string_converter.rb#L498-L534","documentation":"Error \"string conversion expects a Default value or a Hash of type to format mappings, got a '#{string_formats.class}'\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/pops/types/string_converter.rb:516 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"}