{"record":{"id":"b6e365a679bb7363","repo":"puppetlabs/puppet","slug":"no-record-types-defined-cannot-parse-lines","errorCode":null,"errorMessage":"No record types defined; cannot parse lines","messagePattern":"No record types defined; cannot parse lines","errorType":"exception","errorClass":"Puppet::DevError","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/fileparsing.rb","lineNumber":268,"sourceCode":"  # Split a bunch of text into lines and then parse them individually.\n  def parse(text)\n    count = 1\n    lines(text).collect do |line|\n      count += 1\n      val = parse_line(line)\n      if val\n        val\n      else\n        error = Puppet::ResourceError.new(_(\"Could not parse line %{line}\") % { line: line.inspect })\n        error.line = count\n        raise error\n      end\n    end\n  end\n\n  # Handle parsing a single line.\n  def parse_line(line)\n    raise Puppet::DevError, _(\"No record types defined; cannot parse lines\") unless records?\n\n    @record_order.each do |record|\n      # These are basically either text or record lines.\n      method = \"handle_#{record.type}_line\"\n      if respond_to?(method)\n        result = send(method, line, record)\n        if result\n          record.send(:post_parse, result) if record.respond_to?(:post_parse)\n          return result\n        end\n      else\n        raise Puppet::DevError, _(\"Somehow got invalid line type %{record_type}\") % { record_type: record.type }\n      end\n    end\n\n    nil\n  end\n","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/fileparsing.rb#L250-L286","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"# before\nclass Puppet::Provider::Myconf::Myconf < Puppet::Provider::ParsedFile\n  # no record_line => DevError: No record types defined; cannot parse lines\nend\n\n# after\nclass Puppet::Provider::Myconf::Myconf < Puppet::Provider::ParsedFile\n  record_line :myconf, fields: %i[name value], separator: '='\nend","handlingStrategy":"validation","validationCode":"raise Puppet::DevError, 'no record types defined' unless provider.records?\nprovider.parse_line(line)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["puppet","provider","file-parsing","setup","dev-error"],"backgroundTag":"missing-configuration","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}