puppetlabs/puppet · error · Puppet::DevError

Somehow got invalid line type %{record_type}

Error message

Somehow got invalid line type %{record_type}

What it means

parse_line dispatches each declared record to a 'handle_<type>_line' method; only handle_record_line and handle_text_line exist, matching the two legal FileRecord types. If a record with any other type sits in @record_order (only possible by registering a hand-built FileRecord via new_line_type), Puppet raises Puppet::DevError naming the bogus type.

Source

Thrown at lib/puppet/util/fileparsing.rb:280

      end
    end
  end

  # Handle parsing a single line.
  def parse_line(line)
    raise Puppet::DevError, _("No record types defined; cannot parse lines") unless records?

    @record_order.each do |record|
      # These are basically either text or record lines.
      method = "handle_#{record.type}_line"
      if respond_to?(method)
        result = send(method, line, record)
        if result
          record.send(:post_parse, result) if record.respond_to?(:post_parse)
          return result
        end
      else
        raise Puppet::DevError, _("Somehow got invalid line type %{record_type}") % { record_type: record.type }
      end
    end

    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

View on GitHub (pinned to e227c27540)

Solutions

  1. Express the format as :record (fields/regex based) or :text (match based) and put custom logic in process/post_parse/to_line hooks
  2. If a genuinely different line model is needed, pre-transform lines before handing them to FileParsing rather than inventing record types

Example fix

# before
new_line_type(FileRecord.new(:csv, fields: %w[a b c]))
# parse_line => DevError: Somehow got invalid line type csv

# after
record_line :csv, fields: %w[a b c], separator: ','
Defensive patterns

Strategy: validation

Validate before calling

VALID = %i[record text]
types = provider.instance_variable_get(:@record_order).map(&:type)
raise ArgumentError, types.join(',') unless (types - VALID).empty?

Prevention

When it happens

Trigger: Calling new_line_type(FileRecord.new(:xml, fields: [...])) or otherwise registering a record whose type is neither :record nor :text, then parsing any line through the provider.

Common situations: Custom providers extending Puppet's file-parsing internals with new record kinds; monkey-patches that bypass the record_line/text_line DSL.

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


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/5e24931ed7ff527c. Report an issue: GitHub.