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

  1. Give the reference a title: `require => Service['apache']` not `require => 'Service'`
  2. If the value comes from Hiera/variables, ensure it is the full string 'Type[Title]' or an actual Resource object
  3. Guard interpolations: `require => File["${name}"]` fails when $name is '' — assert $name is non-empty first
  4. 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

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


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/1fb40bf60d816325. Report an issue: GitHub.