{"record":{"id":"9e8c6598e1af1924","repo":"puppetlabs/puppet","slug":"must-include-a-list-of-fields","errorCode":null,"errorMessage":"Must include a list of fields","messagePattern":"Must include a list of fields","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/fileparsing.rb","lineNumber":302,"sourceCode":"    nil\n  end\n\n  # Define a new type of record.  These lines get split into hashes.  Valid\n  # options are:\n  # * <tt>:absent</tt>: What to use as value within a line, when a field is\n  #   absent.  Note that in the record object, the literal :absent symbol is\n  #   used, and not this value.  Defaults to \"\".\n  # * <tt>:fields</tt>: The list of fields, as an array.  By default, all\n  #   fields are considered required.\n  # * <tt>:joiner</tt>: How to join fields together.  Defaults to '\\t'.\n  # * <tt>:optional</tt>: Which fields are optional.  If these are missing,\n  #   you'll just get the 'absent' value instead of an ArgumentError.\n  # * <tt>:rts</tt>: Whether to remove trailing whitespace.  Defaults to false.\n  #   If true, whitespace will be removed; if a regex, then whatever matches\n  #   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","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/fileparsing.rb#L284-L320","documentation":"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.","triggerScenarios":"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.","commonSituations":"First-time provider authors omitting fields; copy-paste between text_line and record_line definitions; option hashes assembled at runtime.","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)"],"exampleFix":"# before\nrecord_line :hosts, separator: /\\s+/\n# => ArgumentError: Must include a list of fields\n\n# after\nrecord_line :hosts, fields: %i[ip name_list], separator: /\\s+/","handlingStrategy":"validation","validationCode":"raise ArgumentError, ':fields required' unless options.key?(:fields)\nrecord_line :myline, **options","typeGuard":null,"tryCatchPattern":null,"preventionTips":["record_line always needs :fields; text_line always needs :match","Use options.fetch so a missing key fails loudly where the hash is built"],"tags":["puppet","provider","file-parsing","missing-option"],"backgroundTag":"missing-required-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}