puppetlabs/puppet · error · Puppet::Error
title patterns that use procs are not supported.
Error message
title patterns that use procs are not supported.
What it means
'puppet generate types' (run during r10k/Code Manager deploys for environment isolation) converts each resource type's title_patterns into a pcore type definition in generated Puppet code. A title pattern may bind regex captures to namevars via procs, but a proc cannot be rendered into the DSL, so generation aborts with Puppet::Error when any binding entry is a [name, proc] pair instead of a plain [name].
Source
Thrown at lib/puppet/generate/models/type/type.rb:48
attr_reader :capability
# Initializes a type model.
# @param type [Puppet::Type] The Puppet type to model.
# @return [void]
def initialize(type)
@name = Puppet::Pops::Types::StringConverter.convert(type.name.to_s, '%p')
@doc = type.doc.strip
@properties = type.properties.map { |p| Property.new(p) }
@parameters = type.parameters.map do |name|
Property.new(type.paramclass(name))
end
sc = Puppet::Pops::Types::StringConverter.singleton
@title_patterns = type.title_patterns.to_h do |mapping|
[
sc.convert(mapping[0], '%p'),
sc.convert(mapping[1].map do |names|
next if names.empty?
raise Puppet::Error, _('title patterns that use procs are not supported.') unless names.size == 1
names[0].to_s
end, '%p')
]
end
@isomorphic = type.isomorphic?
# continue to emit capability as false when rendering the ERB
# template, so that pcore modules generated prior to puppet7 can be
# read by puppet7 and vice-versa.
@capability = false
end
def render(template)
template.result(binding)
end
end
end
endView on GitHub (pinned to e227c27540)
Solutions
- Upgrade the module to a version whose type supports pcore generation (many maintainers replaced proc-based title_patterns).
- If the proc is a pass-through, patch the type to bind without a proc: [[:namevar]] instead of [[:namevar, proc { |s| s }]].
- If the type genuinely needs capture transforms, report it to the maintainer and exclude the module from generate types until fixed.
- Verify the fix by re-running 'puppet generate types' in the environment directory and checking the generated .pp.
Example fix
# lib/puppet/type/foobar.rb - before
newtype(:foobar) do
def self.title_patterns
[[%r{^(.*)$}, [[:name, proc { |s| s }]]]]
end
end
# after
newtype(:foobar) do
def self.title_patterns
[[%r{^(.*)$}, [[:name]]]]
end
end Defensive patterns
Strategy: validation
Validate before calling
# before `puppet generate types`, scan loaded types for proc title patterns
require 'puppet'
bad = Puppet::Type.loadall(Puppet::Node::Environment.remote('production'))
.map { |t| Puppet::Type.type(t) }
.flat_map { |t| (t.respond_to?(:title_patterns) ? t.title_patterns : []).map { |(_, binds)| binds } }
.flatten(1)
.select { |b| b.is_a?(Array) && b.size == 2 }
abort 'types with proc title_patterns cannot be generated' unless bad.empty? Try / catch
begin
Puppet::Application[:generate].run_command('types')
rescue Puppet::Error => e
raise if e.message !~ /title patterns that use procs/
warn "skipping type generation: #{e.message}"
end Prevention
- Prefer single-namevar types; avoid composite title patterns in custom types.
- Test 'puppet generate types' in CI for every environment that uses it at deploy time.
- Keep modules current — pcore-compatible title_patterns is a maintained-module requirement.
When it happens
Trigger: An environment contains a native type whose self.title_patterns returns mappings like [[%r{^(.*)/(.*)$}, [[:user, proc { |s| s }], [:group, proc { |s| s }]]]] (entry size 2), and 'puppet generate types' runs — either manually or as a Code Manager/r10k post-deploy hook.
Common situations: Composite-namevar custom types (titles like 'path/line') in modules deployed to Puppet Enterprise with environment isolation; older module versions written before pcore support; upgrading Puppet 5.x to 6/7 where generate-types became a standard deploy step and the deploy starts failing.
Related errors
- Data Type Load Error for type '%{type_name}': %{message}
- a data type must have an interface
- a data type can only have one interface
- a data type can only have one implementation
- attempt to #{action} #{type_name} annotation declared on #{o
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/c865feefaf4816c0.
Report an issue: GitHub.