puppetlabs/puppet · error · ArgumentError
Invalid record type %{record_type}
Error message
Invalid record type %{record_type} What it means
A Puppet::Util::FileParsing FileRecord is created internally by record_line (type :record) and text_line (type :text); initialize interns the type and accepts only those two, raising ArgumentError otherwise. Hitting it means FileRecord.new was called directly with a non-standard type — the record_line/text_line DSL cannot produce this error.
Source
Thrown at lib/puppet/util/fileparsing.rb:66
end
end
def initialize(type,
absent: nil,
block_eval: nil,
fields: nil,
joiner: nil,
match: nil,
optional: nil,
post_parse: nil,
pre_gen: nil,
rollup: nil,
rts: nil,
separator: nil,
to_line: nil,
&block)
@type = type.intern
raise ArgumentError, _("Invalid record type %{record_type}") % { record_type: @type } unless [:record, :text].include?(@type)
@absent = absent
@block_eval = block_eval
@joiner = joiner
@match = match
@rollup = rollup if rollup
@rts = rts
@separator = separator
self.fields = fields if fields
self.optional = optional if optional
self.post_parse = post_parse if post_parse
self.pre_gen = pre_gen if pre_gen
self.to_line = to_line if to_line
if self.type == :record
# Now set defaults.
self.absent ||= ""View on GitHub (pinned to e227c27540)
Solutions
- Use the record_line / text_line DSL, which always passes a valid type
- If constructing FileRecord directly, pass exactly :record or :text
- Model format quirks with :process / :to_line / :post_parse hooks on a legal record instead of a new type
Example fix
# before FileRecord.new(:multiline, fields: %i[content]) # => ArgumentError: Invalid record type multiline # after # use the DSL, which only creates legal types record_line :chunk, fields: %i[content]
Defensive patterns
Strategy: validation
Validate before calling
type = :record raise ArgumentError, 'bad type' unless %i[record text].include?(type) FileRecord.new(type, fields: %w[a b])
Prevention
- Prefer the record_line/text_line DSL over constructing FileRecord directly
- Model line kinds as :record or :text plus hooks, never as new FileRecord types
When it happens
Trigger: Calling Puppet::Util::FileParsing::FileRecord.new(:stream, fields: [...]) or a custom new_line_type wrapper passing an invented type such as :multiline or :csv, instead of going through the DSL.
Common situations: Custom providers copying Puppet internals and inventing new record kinds; monkey-patches that register record types without updating the parse dispatch.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Somehow got invalid line type %{record_type}
- Cannot have fields named %{name}
- Field '%{field}' is required
- Process record type %{record_name} returned non-hash
- No record types defined; cannot parse lines
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/220706d166cdd5d3.
Report an issue: GitHub.