{"record":{"id":"cf700deac7dfe159","repo":"puppetlabs/puppet","slug":"cannot-add-resource-resource-1-after-resource","errorCode":null,"errorMessage":"Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog","messagePattern":"Cannot add resource %(.+?) after %(.+?) because %(.+?) is not yet in the catalog","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/resource/catalog.rb","lineNumber":119,"sourceCode":"      other_title_key = title_key_for_ref(other.ref)\n      idx = @resources.index(other_title_key)\n      if idx.nil?\n        raise ArgumentError, _(\"Cannot add resource %{resource_1} before %{resource_2} because %{resource_2} is not yet in the catalog\") %\n                             { resource_1: resource.ref, resource_2: other.ref }\n      end\n      add_one_resource(resource, idx)\n    end\n  end\n\n  # Add `resources` to the catalog after `other`. WARNING: adding\n  # multiple resources will produce the reverse ordering, e.g. calling\n  # `add_resource_after(A, [B,C])` will result in `[A,C,B]`.\n  def add_resource_after(other, *resources)\n    resources.each do |resource|\n      other_title_key = title_key_for_ref(other.ref)\n      idx = @resources.index(other_title_key)\n      if idx.nil?\n        raise ArgumentError, _(\"Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog\") %\n                             { resource_1: resource.ref, resource_2: other.ref }\n      end\n      add_one_resource(resource, idx + 1)\n    end\n  end\n\n  def add_resource(*resources)\n    resources.each do |resource|\n      add_one_resource(resource)\n    end\n  end\n\n  # @param resource [A Resource] a resource in the catalog\n  # @return [A Resource, nil] the resource that contains the given resource\n  # @api public\n  def container_of(resource)\n    adjacent(resource, :direction => :in)[0]\n  end","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/resource/catalog.rb#L101-L137","documentation":"Error \"Cannot add resource %{resource_1} after %{resource_2} because %{resource_2} is not yet in the catalog\" thrown in puppetlabs/puppet.","triggerScenarios":"Thrown at lib/puppet/resource/catalog.rb:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}