puppetlabs/puppet · error · Puppet::Parser::Compiler::CatalogValidationError
No title provided and %{type} is not a valid resource refere
Error message
No title provided and %{type} is not a valid resource reference What it means
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.
Source
Thrown at lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb:32
end
end
nil
end
private
def validate_relationship(param)
# the referenced resource must exist
refs = param.value.is_a?(Array) ? param.value.flatten : [param.value]
refs.each do |r|
next if r.nil? || r == :undef
res = r.to_s
begin
found = catalog.resource(res)
rescue ArgumentError => e
# Raise again but with file and line information
raise CatalogValidationError.new(e.message, param.file, param.line)
end
unless found
msg = _("Could not find resource '%{res}' in parameter '%{param}'") % { res: res, param: param.name.to_s }
raise CatalogValidationError.new(msg, param.file, param.line)
end
end
end
end
end
View on GitHub (pinned to e227c27540)
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
Example fix
# before
file { '/etc/app.conf':
require => 'File', # no title -> ArgumentError at catalog validation
}
# after
file { '/etc/app.conf':
require => File['/etc/app.defaults'],
} Defensive patterns
Strategy: validation
Validate before calling
# Ruby: check every relationship reference is a valid Type[Title] form before compile
ref = 'Service'
raise ArgumentError, "#{ref} is not a valid resource reference" unless ref.match?(%r{\A[A-Z][A-Za-z0-9_]*(\[[^\[\]]+\])+\z}) Try / catch
begin
compiler.compile
rescue Puppet::Parser::Compiler::CatalogValidationError => e
# e.message already includes the param's file and line
STDERR.puts "invalid relationship reference at #{e.file}:#{e.line}"
raise
end Prevention
- 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}]"
When it happens
Trigger: 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.
Common situations: 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 => ''.
Related errors
- Duplicate declaration: %{resource} is already declared; cann
- Unable to verify the SSL certificate at %{uri}
- Could not find resource '%{res}' in parameter '%{param}'
- Could not deserialize catalog from %{format}: %{detail}
- Both type and title must be given
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/1fb40bf60d816325.
Report an issue: GitHub.