puppetlabs/puppet · error · IniParseError

Property with key %{key} outside of a section

Error message

Property with key %{key} outside of a section

What it means

Error "Property with key %{key} outside of a section" thrown in puppetlabs/puppet.

Source

Thrown at lib/puppet/util/inifile.rb:187

          end
        elsif l.match(INI_CONTINUATION) && section && optname
          # continuation line
          section[optname] += "\n#{l.chomp}"
        elsif (match = l.match(INI_SECTION_NAME))
          # section heading
          section.mark_clean if section

          section_name = match[1]

          section = add_section(section_name)
          optname = nil
        elsif (match = l.match(INI_PROPERTY))
          # the regex strips leading white space from the value, and here we strip the trailing white space as well
          key = match[1]
          val = match[2].rstrip

          if section.nil?
            raise IniParseError, _("Property with key %{key} outside of a section") % { key: key.inspect }
          end

          section[key] = val
          optname = key
        else
          raise IniParseError.new(_("Can't parse line '%{line}'") % { line: l.chomp }, @file, line_num)
        end
      end
      section.mark_clean unless section.nil?
    end

    # @return [Array<Puppet::Util::IniConfig::Section>] All sections defined in
    #   this file.
    def sections
      @contents.select { |entry| entry.is_a? Section }
    end

    # @return [Puppet::Util::IniConfig::Section, nil] The section with the

View on GitHub (pinned to e227c27540)

When it happens

Trigger: Thrown at lib/puppet/util/inifile.rb:187 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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