{"record":{"id":"5e24931ed7ff527c","repo":"puppetlabs/puppet","slug":"somehow-got-invalid-line-type-record-type","errorCode":null,"errorMessage":"Somehow got invalid line type %{record_type}","messagePattern":"Somehow got invalid line type %(.+?)","errorType":"exception","errorClass":"Puppet::DevError","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/fileparsing.rb","lineNumber":280,"sourceCode":"      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\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","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/fileparsing.rb#L262-L298","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom providers extending Puppet's file-parsing internals with new record kinds; monkey-patches that bypass the record_line/text_line DSL.","solutions":["Express the format as :record (fields/regex based) or :text (match based) and put custom logic in process/post_parse/to_line hooks","If a genuinely different line model is needed, pre-transform lines before handing them to FileParsing rather than inventing record types"],"exampleFix":"# before\nnew_line_type(FileRecord.new(:csv, fields: %w[a b c]))\n# parse_line => DevError: Somehow got invalid line type csv\n\n# after\nrecord_line :csv, fields: %w[a b c], separator: ','","handlingStrategy":"validation","validationCode":"VALID = %i[record text]\ntypes = provider.instance_variable_get(:@record_order).map(&:type)\nraise ArgumentError, types.join(',') unless (types - VALID).empty?","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register only :record and :text records; express custom formats via hooks","Avoid new_line_type unless you replicate the DSL's guarantees"],"tags":["puppet","provider","file-parsing","enum","dev-error"],"backgroundTag":"invalid-enum-value","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}