puppetlabs/puppet · error · Puppet::DevError
No record types defined; cannot parse lines
Error message
No record types defined; cannot parse lines
What it means
parse_line iterates the record types a FileParsing provider declared; if none were defined (records? is false) it raises Puppet::DevError 'No record types defined'. It means the provider class includes Puppet::Util::FileParsing but its record_line/text_line definitions never executed — a setup bug, not a data problem.
Source
Thrown at lib/puppet/util/fileparsing.rb:268
# Split a bunch of text into lines and then parse them individually.
def parse(text)
count = 1
lines(text).collect do |line|
count += 1
val = parse_line(line)
if val
val
else
error = Puppet::ResourceError.new(_("Could not parse line %{line}") % { line: line.inspect })
error.line = count
raise error
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
View on GitHub (pinned to e227c27540)
Solutions
- Add at least one record_line (field-based) or text_line (regex-based) definition to the provider class body
- Ensure the definitions run at class-body time, not lazily inside a method
- In tests, load the real provider file so the record registry is populated before parsing
Example fix
# before class Puppet::Provider::Myconf::Myconf < Puppet::Provider::ParsedFile # no record_line => DevError: No record types defined; cannot parse lines end # after class Puppet::Provider::Myconf::Myconf < Puppet::Provider::ParsedFile record_line :myconf, fields: %i[name value], separator: '=' end
Defensive patterns
Strategy: validation
Validate before calling
raise Puppet::DevError, 'no record types defined' unless provider.records? provider.parse_line(line)
Prevention
- Every ParsedFile provider body must call record_line or text_line
- Guard with records? before parsing in early-loaded or generated code
- Load real provider files in tests instead of stubbing the class
When it happens
Trigger: A provider subclass that includes Puppet::Util::FileParsing (or inherits Puppet::Provider::ParsedFile) without any record_line/text_line call in its class body, or code that calls parse_line before the provider class body finished evaluating (autoload or load-order issues).
Common situations: Writing a first parsedfile provider and forgetting the record_line block; test doubles that stub the provider class without its definitions; modules that reopen provider classes at the wrong time.
Related errors
- Process record type %{record_name} returned non-hash
- Somehow got invalid line type %{record_type}
- Cannot have fields named %{name}
- Invalid record type %{record_type}
- Field '%{field}' is required
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/b6e365a679bb7363.
Report an issue: GitHub.