{"record":{"id":"1e47975b88fbe5c0","repo":"puppetlabs/puppet","slug":"you-must-provide-a-match-regex-for-text-lines","errorCode":null,"errorMessage":"You must provide a :match regex for text lines","messagePattern":"You must provide a :match regex for text lines","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/fileparsing.rb","lineNumber":317,"sourceCode":"  #   the regex will be removed.\n  # * <tt>:separator</tt>: The record separator.  Defaults to /\\s+/.\n  def record_line(name, options, &block)\n    raise ArgumentError, _(\"Must include a list of fields\") unless options.include?(:fields)\n\n    record = FileRecord.new(:record, **options, &block)\n    record.name = name.intern\n\n    new_line_type(record)\n  end\n\n  # Are there any record types defined?\n  def records?\n    defined?(@record_types) and !@record_types.empty?\n  end\n\n  # Define a new type of text record.\n  def text_line(name, options, &block)\n    raise ArgumentError, _(\"You must provide a :match regex for text lines\") unless options.include?(:match)\n\n    record = FileRecord.new(:text, **options, &block)\n    record.name = name.intern\n\n    new_line_type(record)\n  end\n\n  # Generate a file from a bunch of hash records.\n  def to_file(records)\n    text = records.collect { |record| to_line(record) }.join(line_separator)\n\n    text += line_separator if trailing_separator\n\n    text\n  end\n\n  # Convert our parsed record into a text record.\n  def to_line(details)","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/fileparsing.rb#L299-L335","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ntext_line :comment\n# => ArgumentError: You must provide a :match regex for text lines\n\n# after\ntext_line :comment, match: /\\A\\s*#/","handlingStrategy":"validation","validationCode":"unless options.key?(:match) && options[:match].is_a?(Regexp)\n  raise ArgumentError, ':match regex required'\nend\ntext_line :mytext, **options","typeGuard":null,"tryCatchPattern":null,"preventionTips":["text_line without match: is always a bug — lint provider definitions","Order records so any catch-all text_line comes last"],"tags":["puppet","provider","file-parsing","missing-option","regex"],"backgroundTag":"missing-required-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}