{"record":{"id":"47dc9d4b99ecb567","repo":"puppetlabs/puppet","slug":"could-not-intern-multiple-from-format-err","errorCode":null,"errorMessage":"Could not intern_multiple from %{format}: %{err}","messagePattern":"Could not intern_multiple from %(.+?): %(.+?)","errorType":"exception","errorClass":"Puppet::Network::FormatHandler::FormatError","httpStatus":null,"severity":"error","filePath":"lib/puppet/network/format_support.rb","lineNumber":24,"sourceCode":"# @api public\nmodule Puppet::Network::FormatSupport\n  def self.included(klass)\n    klass.extend(ClassMethods)\n  end\n\n  module ClassMethods\n    def convert_from(format, data)\n      get_format(format).intern(self, data)\n    rescue => err\n      # TRANSLATORS \"intern\" is a function name and should not be translated\n      raise Puppet::Network::FormatHandler::FormatError, _(\"Could not intern from %{format}: %{err}\") % { format: format, err: err }, err.backtrace\n    end\n\n    def convert_from_multiple(format, data)\n      get_format(format).intern_multiple(self, data)\n    rescue => err\n      # TRANSLATORS \"intern_multiple\" is a function name and should not be translated\n      raise Puppet::Network::FormatHandler::FormatError, _(\"Could not intern_multiple from %{format}: %{err}\") % { format: format, err: err }, err.backtrace\n    end\n\n    def render_multiple(format, instances)\n      get_format(format).render_multiple(instances)\n    rescue => err\n      # TRANSLATORS \"render_multiple\" is a function name and should not be translated\n      raise Puppet::Network::FormatHandler::FormatError, _(\"Could not render_multiple to %{format}: %{err}\") % { format: format, err: err }, err.backtrace\n    end\n\n    def default_format\n      supported_formats[0]\n    end\n\n    def support_format?(name)\n      Puppet::Network::FormatHandler.format(name).supported?(self)\n    end\n\n    def supported_formats","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/network/format_support.rb#L6-L42","documentation":"convert_from_multiple wraps any exception raised while deserializing a list of instances through format.intern_multiple into a FormatError naming the format and the original error. Typical underlying causes: the payload is not a collection (the YAML format raises its own FormatError which then gets wrapped), one element fails parsing, or the class lacks the intern_multiple method (NotImplementedError wrapped).","triggerScenarios":"Klass.convert_from_multiple(:yaml, '--- foo') (scalar document); convert_from_multiple(:json, '[{\"a\":},]') (malformed element); convert_from_multiple(:json, list) on a class without from_json_multiple.","commonSituations":"List endpoints receiving single-object payloads by mistake; batch report/fact uploads with one corrupt element; producers writing YAML.dump(obj) where the consumer expects YAML.dump([obj]).","solutions":["Make the payload a collection (YAML sequence / JSON array) of per-instance documents or Hashes.","Pre-parse and shape-check: data = Puppet::Util::Yaml.safe_load(text, []); reject unless data.respond_to?(:collect).","Fix the producer to serialize arrays when a list is expected.","Use convert_from for genuine single documents."],"exampleFix":"# before\nWidget.convert_from_multiple(:yaml, File.read('widgets.yaml'))\n# widgets.yaml contains '--- 42' → wrapped FormatError\n\n# after — widgets.yaml is a sequence\n# ---\n# - id: 1\n# - id: 2\nlist = Widget.convert_from_multiple(:yaml, File.read('widgets.yaml'))","handlingStrategy":"validation","validationCode":"data = format == :json ? Puppet::Util::Json.load(text) : Puppet::Util::Yaml.safe_load(text, [])\nraise ArgumentError, 'expected a collection of instances' unless data.respond_to?(:collect)\nlist = Klass.convert_from_multiple(format, text)","typeGuard":null,"tryCatchPattern":"begin\n  list = Klass.convert_from_multiple(fmt, text)\nrescue Puppet::Network::FormatHandler::FormatError => e\n  # message embeds the real cause: non-collection, parse error, or missing method\n  warn e.message\n  list = []\nend","preventionTips":["Dump arrays, not scalars, when producers write list payloads.","Pre-check respond_to?(:collect) on loaded data.","Validate each element is a Hash before interning.","Version-lock producers and consumers."],"tags":["puppet","ruby","serialization","yaml","json","deserialization"],"backgroundTag":"deserialization-failed","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}