puppetlabs/puppet · error · ArgumentError
Must include a list of fields
Error message
Must include a list of fields
What it means
record_line defines a field-based record type for a FileParsing provider; the :fields option (the list of columns a line splits into) is mandatory. If the options hash has no :fields key, ArgumentError is raised immediately at provider-definition time.
Source
Thrown at lib/puppet/util/fileparsing.rb:302
nil
end
# Define a new type of record. These lines get split into hashes. Valid
# options are:
# * <tt>:absent</tt>: What to use as value within a line, when a field is
# absent. Note that in the record object, the literal :absent symbol is
# used, and not this value. Defaults to "".
# * <tt>:fields</tt>: The list of fields, as an array. By default, all
# fields are considered required.
# * <tt>:joiner</tt>: How to join fields together. Defaults to '\t'.
# * <tt>:optional</tt>: Which fields are optional. If these are missing,
# you'll just get the 'absent' value instead of an ArgumentError.
# * <tt>:rts</tt>: Whether to remove trailing whitespace. Defaults to false.
# If true, whitespace will be removed; if a regex, then whatever matches
# the regex will be removed.
# * <tt>:separator</tt>: The record separator. Defaults to /\s+/.
def record_line(name, options, &block)
raise ArgumentError, _("Must include a list of fields") unless options.include?(:fields)
record = FileRecord.new(:record, **options, &block)
record.name = name.intern
new_line_type(record)
end
# Are there any record types defined?
def records?
defined?(@record_types) and !@record_types.empty?
end
# Define a new type of text record.
def text_line(name, options, &block)
raise ArgumentError, _("You must provide a :match regex for text lines") unless options.include?(:match)
record = FileRecord.new(:text, **options, &block)
record.name = name.internView on GitHub (pinned to e227c27540)
Solutions
- Add fields: %i[col1 col2 ...] naming every parsed column
- If the line is matched by regex rather than split into columns, use text_line with :match instead
- When options are built dynamically, assert the key with options.fetch(:fields)
Example fix
# before record_line :hosts, separator: /\s+/ # => ArgumentError: Must include a list of fields # after record_line :hosts, fields: %i[ip name_list], separator: /\s+/
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, ':fields required' unless options.key?(:fields) record_line :myline, **options
Prevention
- record_line always needs :fields; text_line always needs :match
- Use options.fetch so a missing key fails loudly where the hash is built
When it happens
Trigger: record_line :hosts, separator: /\s+/ with no fields: key — a typo'd options hash, dynamically built options that drop the key, or a line that should actually have been declared with text_line.
Common situations: First-time provider authors omitting fields; copy-paste between text_line and record_line definitions; option hashes assembled at runtime.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- You must provide a :match regex for text lines
- Cannot have fields named %{name}
- Invalid record type %{record_type}
- Field '%{field}' is required
- Process record type %{record_name} returned non-hash
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/9e8c6598e1af1924.
Report an issue: GitHub.