{"record":{"id":"19ca210b68b33f51","repo":"puppetlabs/puppet","slug":"could-not-find-resource-res-in-parameter-p","errorCode":null,"errorMessage":"Could not find resource '%{res}' in parameter '%{param}'","messagePattern":"Could not find resource '%(.+?)' in parameter '%(.+?)'","errorType":"validation","errorClass":"Puppet::Parser::Compiler::CatalogValidationError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb","lineNumber":36,"sourceCode":"\n    private\n\n    def validate_relationship(param)\n      # the referenced resource must exist\n      refs = param.value.is_a?(Array) ? param.value.flatten : [param.value]\n      refs.each do |r|\n        next if r.nil? || r == :undef\n\n        res = r.to_s\n        begin\n          found = catalog.resource(res)\n        rescue ArgumentError => e\n          # Raise again but with file and line information\n          raise CatalogValidationError.new(e.message, param.file, param.line)\n        end\n        unless found\n          msg = _(\"Could not find resource '%{res}' in parameter '%{param}'\") % { res: res, param: param.name.to_s }\n          raise CatalogValidationError.new(msg, param.file, param.line)\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":18,"sourceCodeEnd":42,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb#L18-L42","documentation":"After parsing a relationship parameter succeeds, the validator checks the referenced resource actually exists in the compiled catalog (relationship_validator.rb:33-38). `catalog.resource('Type[Title]')` returns nil when no resource with that type and title was declared, collected, or realized, so the catalog cannot contain the dependency edge and validation aborts with CatalogValidationError. It means the reference is well-formed but points at a resource that never made it into the catalog.","triggerScenarios":"`require => File['/etc/app.conf']` where that file resource is never declared; `require => Class['profile::web']` when that class is not declared anywhere (include/contain/class {'...'}); referencing a resource declared inside a class that is not included on this node; relying on a resource realized by a collector with a filter that matches nothing (<<| |>> with no matches); title case mismatch such as File['/ETC/app'] vs declared File['/etc/app'] for types with case-insensitive titles.","commonSituations":"Refactoring splits a class and the require target moves to a profile that is no longer included; node classification (ENC/Hiera) stops declaring a class but another class still requires it; exported resources not yet collected on first run of a fresh node; typos in long file paths inside require brackets; relying on resource defaults or virtual resources (@file) without realizing them.","solutions":["Declare the missing resource in the same or an included class: add `file { '/etc/app.conf': ensure => file }`","For class references, make sure the class is declared: `include profile::web` on this node before something requires Class['profile::web']","Realize virtual resources (`realize(File['/etc/app.conf'])`) or make sure the collector filter matches","Check exact title equality (path case, trailing slashes) against the declaration"],"exampleFix":"# before\nservice { 'app':\n  ensure  => running,\n  require => File['/etc/app.conf'],  # never declared -> validation error\n}\n# after\nfile { '/etc/app.conf':\n  ensure => file,\n}\nservice { 'app':\n  ensure  => running,\n  require => File['/etc/app.conf'],\n}","handlingStrategy":"validation","validationCode":"# Ruby: verify a reference resolves before compiling\ncat = compiler.compile rescue nil\n# or proactively on an existing catalog:\nraise ArgumentError, 'File[/etc/app.conf] not in catalog' unless catalog.resource('File[/etc/app.conf]')","typeGuard":null,"tryCatchPattern":"begin\n  compiler.compile\nrescue Puppet::Parser::Compiler::CatalogValidationError => e\n  # message names the exact missing reference and the parameter that cited it\n  raise unless e.message.include?(\"Could not find resource\")\nend","preventionTips":["Declare a resource (or include its class) in the same profile that requires it","Do not require classes that node classification might not assign; model that as data instead","For exported resources, tolerate the first-run gap: guard with defined() or restructure ordering","Check title exactness (paths, case) between declaration and reference"],"tags":["puppet","catalog","dependencies","require","resource-not-found"],"backgroundTag":"missing-resource-dependency","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}