puppetlabs/puppet · error · ArgumentError
No format matches the given format name or mime-type (%{form
Error message
No format matches the given format name or mime-type (%{format}) What it means
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.
Source
Thrown at lib/puppet/network/format_handler.rb:69
@formats.values.find { |format| format.mime == mimetype }
end
# Return a format name given:
# * a format name
# * a mime-type
# * a format instance
def self.format_to_canonical_name(format)
case format
when Puppet::Network::Format
out = format
when %r{\w+/\w+}
out = mime(format)
else
out = format(format)
end
if out.nil?
raise ArgumentError, _("No format matches the given format name or mime-type (%{format})") % { format: format }
end
out.name
end
# Determine which of the accepted formats should be used given what is supported.
#
# @param accepted [Array<String, Symbol>] the accepted formats in a form a
# that generally conforms to an HTTP Accept header. Any quality specifiers
# are ignored and instead the formats are simply in strict preference order
# (most preferred is first)
# @param supported [Array<Symbol>] the names of the supported formats (the
# most preferred format is first)
# @return [Array<Puppet::Network::Format>] the most suitable formats that
# are both accepted and supported
# @api private
def self.most_suitable_formats_for(accepted, supported)
accepted.collect do |format|View on GitHub (pinned to e227c27540)
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.
Example fix
# before
Puppet::Network::FormatHandler.format_to_canonical_name('pson')
# => ArgumentError: No format matches the given format name or mime-type (pson)
# after
Puppet::Network::FormatHandler.format_to_canonical_name('json') # => :json Defensive patterns
Strategy: validation
Validate before calling
registered = Puppet::Network::FormatHandler.formats.map(&:to_s) chosen = registered.include?(requested.to_s) ? requested : 'json' name = Puppet::Network::FormatHandler.format_to_canonical_name(chosen)
Type guard
def known_format?(name_or_mime)
return true if name_or_mime.is_a?(Puppet::Network::Format)
str = name_or_mime.to_s
!Puppet::Network::FormatHandler.format(str).nil? ||
(str =~ %r{\w+/\w+} && !Puppet::Network::FormatHandler.mime(str).nil?)
end Try / catch
begin canonical = Puppet::Network::FormatHandler.format_to_canonical_name(raw) rescue ArgumentError canonical = :json # json is registered in every Puppet end
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- #{klass} does not respond to #{intern_multiple_method}; can
- #{instance.class} does not respond to #{render_method}; can
- %{klass} does not respond to %{method}; can not render multi
- Could not render_multiple to %{format}: %{err}
- Could not render to %{format}: %{err}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/e4f05456102ff7bf.
Report an issue: GitHub.