puppetlabs/puppet · error · ArgumentError

Cannot add resource %{resource_1} after %{resource_2} becaus

Error message

Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog

What it means

Error "Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog" thrown in puppetlabs/puppet.

Source

Thrown at lib/puppet/resource/catalog.rb:119

      other_title_key = title_key_for_ref(other.ref)
      idx = @resources.index(other_title_key)
      if idx.nil?
        raise ArgumentError, _("Cannot add resource %{resource_1} before %{resource_2} because %{resource_2} is not yet in the catalog") %
                             { resource_1: resource.ref, resource_2: other.ref }
      end
      add_one_resource(resource, idx)
    end
  end

  # Add `resources` to the catalog after `other`. WARNING: adding
  # multiple resources will produce the reverse ordering, e.g. calling
  # `add_resource_after(A, [B,C])` will result in `[A,C,B]`.
  def add_resource_after(other, *resources)
    resources.each do |resource|
      other_title_key = title_key_for_ref(other.ref)
      idx = @resources.index(other_title_key)
      if idx.nil?
        raise ArgumentError, _("Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog") %
                             { resource_1: resource.ref, resource_2: other.ref }
      end
      add_one_resource(resource, idx + 1)
    end
  end

  def add_resource(*resources)
    resources.each do |resource|
      add_one_resource(resource)
    end
  end

  # @param resource [A Resource] a resource in the catalog
  # @return [A Resource, nil] the resource that contains the given resource
  # @api public
  def container_of(resource)
    adjacent(resource, :direction => :in)[0]
  end

View on GitHub (pinned to e227c27540)

When it happens

Trigger: Thrown at lib/puppet/resource/catalog.rb:119 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/cf700deac7dfe159. Report an issue: GitHub.