puppetlabs/puppet · error · ArgumentError
You must provide a :match regex for text lines
Error message
You must provide a :match regex for text lines
What it means
text_line defines a regex-matched record type for a FileParsing provider; the :match option decides whether a line belongs to the type, so it is mandatory. Without it, ArgumentError is raised at definition time.
Source
Thrown at lib/puppet/util/fileparsing.rb:317
# 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.intern
new_line_type(record)
end
# Generate a file from a bunch of hash records.
def to_file(records)
text = records.collect { |record| to_line(record) }.join(line_separator)
text += line_separator if trailing_separator
text
end
# Convert our parsed record into a text record.
def to_line(details)View on GitHub (pinned to e227c27540)
Solutions
- Add match: /pattern/ describing exactly the lines this record owns
- For delimited columns use record_line with :fields instead
- A catch-all final record like text_line :catchall, match: /.*/ is the idiomatic way to absorb unmatched lines
Example fix
# before text_line :comment # => ArgumentError: You must provide a :match regex for text lines # after text_line :comment, match: /\A\s*#/
Defensive patterns
Strategy: validation
Validate before calling
unless options.key?(:match) && options[:match].is_a?(Regexp) raise ArgumentError, ':match regex required' end text_line :mytext, **options
Prevention
- text_line without match: is always a bug — lint provider definitions
- Order records so any catch-all text_line comes last
When it happens
Trigger: text_line :comment with no options, or with fields: instead of match: — i.e. forgetting the match: /.../ regex, or using text_line for what is really a field-split line.
Common situations: Providers modeling comment or blank lines (as Puppet's own host/port providers do with text_line) where the regex is accidentally dropped during edits.
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
- Must include a list of fields
- 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/1e47975b88fbe5c0.
Report an issue: GitHub.