{"record":{"id":"94866ad28ba10d22","repo":"puppetlabs/puppet","slug":"could-not-parse-messagepack-data-for-indirection","errorCode":null,"errorMessage":"Could not parse MessagePack data for %{indirection} %{key}: %{detail}","messagePattern":"Could not parse MessagePack data for %(.+?) %(.+?): %(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/indirector/msgpack.rb","lineNumber":76,"sourceCode":"\n  private\n\n  def load_msgpack_from_file(file, key)\n    msgpack = nil\n\n    begin\n      msgpack = Puppet::FileSystem.read(file, :encoding => 'utf-8')\n    rescue Errno::ENOENT\n      return nil\n    rescue => detail\n      # TRANSLATORS \"MessagePack\" is a program name and should not be translated\n      raise Puppet::Error, _(\"Could not read MessagePack data for %{indirection} %{key}: %{detail}\") % { indirection: indirection.name, key: key, detail: detail }, detail.backtrace\n    end\n\n    begin\n      from_msgpack(msgpack)\n    rescue => detail\n      raise Puppet::Error, _(\"Could not parse MessagePack data for %{indirection} %{key}: %{detail}\") % { indirection: indirection.name, key: key, detail: detail }, detail.backtrace\n    end\n  end\n\n  def from_msgpack(text)\n    model.convert_from('msgpack', text)\n  end\n\n  def to_msgpack(object)\n    object.render('msgpack')\n  end\nend\n","sourceCodeStart":58,"sourceCodeEnd":88,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/indirector/msgpack.rb#L58-L88","documentation":"Raised by the MessagePack terminus when the cache file was read successfully but model.convert_from('msgpack', data) fails during deserialization. It means the bytes on disk are not valid MessagePack for the model: a truncated file (agent killed mid-write), a file written by a different serializer (YAML or JSON content renamed/dropped into a .msgpack path), or data serialized by an incompatible msgpack gem version.","triggerScenarios":"Calling find on an indirection whose terminus is msgpack (cache_terminus = msgpack) when the .msgpack file is corrupt: e.g., the process was OOM-killed while Puppet::FileSystem.replace_file was writing, an operator hand-edited the cache file, or a YAML cache file from a prior terminus setting was left in place after switching to msgpack.","commonSituations":"Switching catalog cache_terminus from yaml/json to msgpack without clearing the old cache directory; disk-full conditions that truncated writes; restoring vardir from a backup made with a different serialization setting; msgpack gem major-version upgrades that change symbol/string handling.","solutions":["Delete the offending cache file named in the error (rm <vardir>/<indirection>/<key>.msgpack); the next find will rebuild it","Clear the whole cache directory if multiple entries are affected: find $(puppet config print vardir) -name '*.msgpack' -delete","If you recently changed cache_terminus, purge stale files written by the previous format before relying on the new terminus","Verify the msgpack gem version matches across agents/servers (gem list msgpack) when caches are shared","Check for disk-full (df -h) or OOM kills in dmesg if corruption recurs, since those truncate writes"],"exampleFix":"# before\n# Error: Could not parse MessagePack data for catalog web01: unexpected token...\n\n# after: purge the corrupt cache and re-fetch\nrm -f \"$(puppet config print vardir)/catalog/$(puppet config print certname).msgpack\"\npuppet agent -t   # recompiles and re-caches cleanly","handlingStrategy":"fallback","validationCode":"file = File.join(Puppet[:vardir].to_s, indirection_name, \"#{key}.msgpack\")\nif Puppet::FileSystem.exist?(file)\n  data = Puppet::FileSystem.read(file, encoding: 'utf-8') rescue nil\n  return unless data\n  require 'msgpack'\n  begin; MessagePack.unpack(data); rescue => e; Puppet.warning \"stale cache, removing\"; File.delete(file); end\nend","typeGuard":null,"tryCatchPattern":"begin\n  catalog = Puppet::Resource::Catalog.indirection.find(key)\nrescue Puppet::Error => e\n  raise unless e.message.start_with?('Could not parse MessagePack data')\n  File.delete(File.join(Puppet[:vardir].to_s, 'catalog', \"#{key}.msgpack\")) rescue nil\n  catalog = nil  # force full compile path\nend","preventionTips":["Purge old-format cache files whenever you change cache_terminus","Keep msgpack gem versions pinned identically across the fleet","Treat caches as disposable: never hand-edit .msgpack files"],"tags":["puppet","msgpack","cache-corruption","deserialization"],"backgroundTag":"msgpack-decode-error","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}