puppetlabs/puppet · error · ArgumentError
Cannot add resource %{resource_1} before %{resource_2} becau
Error message
Cannot add resource %{resource_1} before %{resource_2} because %{resource_2} is not yet in the catalog What it means
Error "Cannot add resource %{resource_1} before %{resource_2} because %{resource_2} is not yet in the catalog" thrown in puppetlabs/puppet.
Source
Thrown at lib/puppet/resource/catalog.rb:104
# Returns [nil, nil] if '[' ']' not detected.
#
def title_key_for_ref(ref)
s = ref.index('[')
e = ref.rindex(']')
if s && e && e > s
a = [ref[0, s], ref[s + 1, e - s - 1]]
else
a = [nil, nil]
end
a
end
def add_resource_before(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} 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)View on GitHub (pinned to e227c27540)
When it happens
Trigger: Thrown at lib/puppet/resource/catalog.rb:104 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/5847ed86ea4a7f7e.
Report an issue: GitHub.