{"record":{"id":"1fb40bf60d816325","repo":"puppetlabs/puppet","slug":"no-title-provided-and-type-is-not-a-valid-resou","errorCode":null,"errorMessage":"No title provided and %{type} is not a valid resource reference","messagePattern":"No title provided and %(.+?) is not a valid resource reference","errorType":"validation","errorClass":"Puppet::Parser::Compiler::CatalogValidationError","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb","lineNumber":32,"sourceCode":"        end\n      end\n      nil\n    end\n\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":14,"sourceCodeEnd":42,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb#L14-L42","documentation":"During catalog validation, the relationship validator walks every `before/require/notify/subscribe` parameter, stringifies each value, and calls catalog.resource(res). That lookup constructs a Puppet::Resource from the string; if the string is not a valid `Type[Title]` reference, Puppet::Resource.extract_type_and_title (lib/puppet/resource.rb:597) raises ArgumentError \"No title provided and %{type} is not a valid resource reference\". The validator rescues it (relationship_validator.rb:30-32) and re-raises it as CatalogValidationError with the manifest file and line attached. So: a relationship metaparameter value is a bare type name (or otherwise unparseable reference) with no title.","triggerScenarios":"A manifest sets `require => 'Service'` (bare capitalized type, no [title]), `before => Exec` (a Class/Type object stringified to just its name), or a variable that evaluates to a string like 'File' instead of File['/x']. Any catalog whose compiler reaches relationship validation with such a param raises this from Puppet::Parser::Compiler::CatalogValidationError.","commonSituations":"Passing a type reference without brackets in DSL (`require => Class` instead of `Class['apache']`); storing resource refs in Hiera as plain strings and forgetting the [title] part; interpolating a title variable that is empty/undef so the reference collapses to 'Type'; refactoring that renames a variable holding a title, leaving `require => \"File[${title}]\"` with title => ''.","solutions":["Give the reference a title: `require => Service['apache']` not `require => 'Service'`","If the value comes from Hiera/variables, ensure it is the full string 'Type[Title]' or an actual Resource object","Guard interpolations: `require => File[\"${name}\"]` fails when $name is '' — assert $name is non-empty first","Use the file/line reported in the CatalogValidationError to jump straight to the offending parameter"],"exampleFix":"# before\nfile { '/etc/app.conf':\n  require => 'File',   # no title -> ArgumentError at catalog validation\n}\n# after\nfile { '/etc/app.conf':\n  require => File['/etc/app.defaults'],\n}","handlingStrategy":"validation","validationCode":"# Ruby: check every relationship reference is a valid Type[Title] form before compile\nref = 'Service'\nraise ArgumentError, \"#{ref} is not a valid resource reference\" unless ref.match?(%r{\\A[A-Z][A-Za-z0-9_]*(\\[[^\\[\\]]+\\])+\\z})","typeGuard":null,"tryCatchPattern":"begin\n  compiler.compile\nrescue Puppet::Parser::Compiler::CatalogValidationError => e\n  # e.message already includes the param's file and line\n  STDERR.puts \"invalid relationship reference at #{e.file}:#{e.line}\"\n  raise\nend","preventionTips":["Always write relationship metaparams with brackets: require => File['/x'], never bare strings","When refs come from Hiera, store them as 'Type[Title]' strings or use the resource() function","Assert interpolated titles are non-empty before using them in require => \"Type[${title}]\""],"tags":["puppet","catalog","resource-reference","relationship-validator","compile-error"],"backgroundTag":"invalid-resource-reference","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}