{"record":{"id":"e4f05456102ff7bf","repo":"puppetlabs/puppet","slug":"no-format-matches-the-given-format-name-or-mime-ty","errorCode":null,"errorMessage":"No format matches the given format name or mime-type (%{format})","messagePattern":"No format matches the given format name or mime-type \\(%(.+?)\\)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/network/format_handler.rb","lineNumber":69,"sourceCode":"    @formats.values.find { |format| format.mime == mimetype }\n  end\n\n  # Return a format name given:\n  #  * a format name\n  #  * a mime-type\n  #  * a format instance\n  def self.format_to_canonical_name(format)\n    case format\n    when Puppet::Network::Format\n      out = format\n    when %r{\\w+/\\w+}\n      out = mime(format)\n    else\n      out = format(format)\n    end\n\n    if out.nil?\n      raise ArgumentError, _(\"No format matches the given format name or mime-type (%{format})\") % { format: format }\n    end\n\n    out.name\n  end\n\n  # Determine which of the accepted formats should be used given what is supported.\n  #\n  # @param accepted [Array<String, Symbol>] the accepted formats in a form a\n  #   that generally conforms to an HTTP Accept header. Any quality specifiers\n  #   are ignored and instead the formats are simply in strict preference order\n  #   (most preferred is first)\n  # @param supported [Array<Symbol>] the names of the supported formats (the\n  #   most preferred format is first)\n  # @return [Array<Puppet::Network::Format>] the most suitable formats that\n  #   are both accepted and supported\n  # @api private\n  def self.most_suitable_formats_for(accepted, supported)\n    accepted.collect do |format|","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/network/format_handler.rb#L51-L87","documentation":"format_to_canonical_name normalizes whatever the caller calls a 'format' — a Format instance, a mime-type string matching \\w+/\\w+ (e.g. 'application/json'), or a bare name — to the canonical name of a registered format. If every lookup returns nil (nothing registered under that name or mime type in this process), ArgumentError is raised: the format is unknown here, regardless of whether other Puppet versions or plugins know it.","triggerScenarios":"Any path that canonicalizes caller input: REST request handling with an unknown Content-Type/Accept ('application/x-foo'), Puppet::Network::FormatHandler.format_to_canonical_name('pson') on Puppet versions where pson was removed, or convert_from(:msgpack, ...) without the msgpack gem loaded.","commonSituations":"Older tooling still asking for 'pson' against Puppet 6+; typo'd format parameters; custom formats registered by a plugin that is not loaded on this node; mime strings that do not match the \\w+/\\w+ pattern.","solutions":["Use formats registered in this process: json and yaml always, msgpack when its gem is loaded (check Puppet::Network::FormatHandler.formats).","Register the custom format before use: Puppet::Network::FormatHandler.create(:foo, :mime => 'application/foo') { ... } in a plugin loaded on every node that handles it.","Send well-formed mime types ('application/json') so the mime branch can match.","For legacy clients, serve json — pson was removed and must not be requested."],"exampleFix":"# before\nPuppet::Network::FormatHandler.format_to_canonical_name('pson')\n# => ArgumentError: No format matches the given format name or mime-type (pson)\n\n# after\nPuppet::Network::FormatHandler.format_to_canonical_name('json') # => :json","handlingStrategy":"validation","validationCode":"registered = Puppet::Network::FormatHandler.formats.map(&:to_s)\nchosen = registered.include?(requested.to_s) ? requested : 'json'\nname = Puppet::Network::FormatHandler.format_to_canonical_name(chosen)","typeGuard":"def known_format?(name_or_mime)\n  return true if name_or_mime.is_a?(Puppet::Network::Format)\n  str = name_or_mime.to_s\n  !Puppet::Network::FormatHandler.format(str).nil? ||\n    (str =~ %r{\\w+/\\w+} && !Puppet::Network::FormatHandler.mime(str).nil?)\nend","tryCatchPattern":"begin\n  canonical = Puppet::Network::FormatHandler.format_to_canonical_name(raw)\nrescue ArgumentError\n  canonical = :json # json is registered in every Puppet\nend","preventionTips":["Whitelist client-supplied format names and mime types against FormatHandler.formats.","Standardize on json/yaml; drop pson from legacy integrations.","Load custom format plugins on all nodes that parse those payloads.","Pin integration tests to the production Puppet version — the format registry differs across releases."],"tags":["puppet","ruby","serialization","formats","content-negotiation","http"],"backgroundTag":"unsupported-content-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}