puppetlabs/puppet · error · NotImplementedError
#{klass} does not respond to #{intern_multiple_method}; can
Error message
#{klass} does not respond to #{intern_multiple_method}; can not intern multiple instances from #{mime} What it means
A Puppet::Network::Format binds a mime type to named methods on the classes it can serialize. intern_multiple(klass, text) deserializes many instances at once by calling the format's intern_multiple_method (for json, from_json_multiple) on the class; when the class does not respond to that method, this NotImplementedError is raised — the format exists, but this class never implemented the multiple-instance entry point.
Source
Thrown at lib/puppet/network/format.rb:61
end
raise ArgumentError, _("Unsupported option(s) %{options_list}") % { options_list: @options.keys } unless @options.empty?
@options = nil
instance_eval(&block) if block_given?
end
def intern(klass, text)
return klass.send(intern_method, text) if klass.respond_to?(intern_method)
raise NotImplementedError, "#{klass} does not respond to #{intern_method}; can not intern instances from #{mime}"
end
def intern_multiple(klass, text)
return klass.send(intern_multiple_method, text) if klass.respond_to?(intern_multiple_method)
raise NotImplementedError, "#{klass} does not respond to #{intern_multiple_method}; can not intern multiple instances from #{mime}"
end
def mime=(mime)
@mime = mime.to_s.downcase
end
def render(instance)
return instance.send(render_method) if instance.respond_to?(render_method)
raise NotImplementedError, "#{instance.class} does not respond to #{render_method}; can not render instances to #{mime}"
end
def render_multiple(instances)
# This method implicitly assumes that all instances are of the same type.
return instances[0].class.send(render_multiple_method, instances) if instances[0].class.respond_to?(render_multiple_method)
raise NotImplementedError, _("%{klass} does not respond to %{method}; can not render multiple instances to %{mime}") %
{ klass: instances[0].class, method: render_multiple_method, mime: mime }View on GitHub (pinned to e227c27540)
Solutions
- Define the missing class method on your model — for the json format: def self.from_json_multiple(text) ... end (mirror whatever intern_multiple_method the format names).
- Check what the class supports and stay inside it: Klass.supported_formats — only call convert_from_multiple for formats listed there.
- If you own the format definition, provide the implementation inline: Puppet::Network::FormatHandler.create(:foo, ...) { intern_multiple { |klass, text| ... } }.
- For single payloads call convert_from (intern) instead of the multiple variant.
Example fix
# before
class Widget
include Puppet::Network::FormatSupport
def self.from_json(text) = Widget.new(Puppet::Util::Json.load(text))
end
Widget.convert_from_multiple(:json, '[{"id":1}]')
# => NotImplementedError: Widget does not respond to from_json_multiple
# after
class Widget
def self.from_json(text) = Widget.new(Puppet::Util::Json.load(text))
def self.from_json_multiple(text) = Puppet::Util::Json.load(text).map { |h| Widget.new(h) }
end Defensive patterns
Strategy: type-guard
Validate before calling
fmt = Puppet::Network::FormatHandler.format(:json) abort 'json format not registered' if fmt.nil? abort 'Widget lacks multiple interning' unless Widget.respond_to?(fmt.intern_multiple_method) list = Widget.convert_from_multiple(:json, payload)
Type guard
def interns_multiple?(klass, format_name) fmt = Puppet::Network::FormatHandler.format(format_name) !fmt.nil? && klass.respond_to?(fmt.intern_multiple_method) end
Try / catch
begin
Widget.convert_from_multiple(:json, payload)
rescue NotImplementedError => e
raise unless e.message.include?('does not respond to')
# degrade to per-item interning
Puppet::Util::Json.load(payload).map { |h| Widget.convert_from(:json, Puppet::Util::Json.dump(h)) }
end Prevention
- When mixing in FormatSupport, implement the full method set (from_*, from_*_multiple, to_*) for every advertised format.
- Route external format choices through supported_formats instead of raw input.
- For custom formats, wire intern_multiple to a proc in the format block rather than a method name.
- Unit-test multi-instance round-trips, not only single objects.
When it happens
Trigger: Klass.convert_from_multiple(:json, '[...]') (FormatSupport) or format.intern_multiple(klass, text) where klass lacks the method named by the format's intern_multiple_method — e.g. a custom model defining from_json but not the multiple variant, or a custom format registered without an intern_multiple implementation.
Common situations: Custom indirected models (faces, report handlers) that only implement single-object parsing; formats created with Puppet::Network::FormatHandler.create whose method names match nothing on the model; Puppet versions where a model lacks msgpack interning.
Related errors
- #{instance.class} does not respond to #{render_method}; can
- %{klass} does not respond to %{method}; can not render multi
- No format matches the given format name or mime-type (%{form
- 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/6019131fd5104891.
Report an issue: GitHub.