puppetlabs/puppet · error · ArgumentError
Parsing of type string '"%{type_string}"' failed with messag
Error message
Parsing of type string '"%{type_string}"' failed with message: <%{message}>.
What it means
When a dispatch signature is assembled, every String type reference is parsed with the Pops TypeParser. If parsing fails, internal_type_parse re-raises the parser's message wrapped in this ArgumentError. The error names the exact offending type string, so a typo or unbalanced bracket is easy to locate.
Source
Thrown at lib/puppet/functions.rb:595
# Handles creation of a callable type from strings specifications of puppet
# types and allows the min/max occurs of the given types to be given as one
# or two integer values at the end. The given block_type should be
# Optional[Callable], Callable, or nil.
#
# @api private
def create_callable(types, block_type, return_type, from, to)
mapped_types = types.map do |t|
t.is_a?(Puppet::Pops::Types::PAnyType) ? t : internal_type_parse(t, loader)
end
param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))
return_type = internal_type_parse(return_type, loader) unless return_type.nil? || return_type.is_a?(Puppet::Pops::Types::PAnyType)
Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)
end
def internal_type_parse(type_string, loader)
Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)
rescue StandardError => e
raise ArgumentError, _("Parsing of type string '\"%{type_string}\"' failed with message: <%{message}>.\n") % {
type_string: type_string,
message: e.message
}
end
private :internal_type_parse
end
# The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual
# type aliases given by the function's author.
#
class LocalTypeAliasesBuilder
attr_reader :local_types, :parser, :loader
def initialize(loader, name)
@loader = Puppet::Pops::Loader::PredefinedLoader.new(loader, :"local_function_#{name}", loader.environment)
@local_types = []
# get the shared parser used by puppet's compiler
@parser = Puppet::Pops::Parser::EvaluatingParser.singleton()View on GitHub (pinned to e227c27540)
Solutions
- Copy the exact quoted type_string out of the message and fix it: check spelling against the Puppet type reference and balance all brackets.
- Verify the corrected string parses: Puppet::Pops::Types::TypeParser.singleton.parse('YourType') in a console.
- If the string references a local alias, make sure local_types declares it and that its own right-hand side is valid.
- For third-party functions, match the module release to your Puppet version; type syntax support varies.
Example fix
# before param 'Strin', :s param 'Array[String', :xs # after param 'String', :s param 'Array[String]', :xs
Defensive patterns
Strategy: validation
Validate before calling
# Fail fast with your own message: pre-parse every type string used in dispatches %w[String Integer Array[String] Optional[Hash]].each do |t| Puppet::Pops::Types::TypeParser.singleton.parse(t) end
Try / catch
begin
Puppet::Pops::Types::TypeParser.singleton.parse(candidate_type)
rescue StandardError => e
raise ArgumentError, "fix type string '#{candidate_type}': #{e.message}"
end Prevention
- Pre-parse type strings in a console before committing function code.
- Balance every bracket; check spelling against the Puppet type reference.
- Keep local type aliases near the functions that use them, in local_types.
When it happens
Trigger: param 'Strin', :s (typo), param 'Array[String', :xs (unbalanced bracket), or a self-referencing alias that the parser cannot resolve during parse. It usually surfaces nested inside 'Function Load Error' because create_function wraps it.
Common situations: Typos in type names; missing closing brackets after edits; using type aliases that are not in scope for the function's loader; Puppet version differences in supported type syntax.
Related errors
- A required parameter cannot be added after an optional param
- A required repeated parameter cannot be added after an optio
- Parameters cannot be added after a block parameter
- Parameters cannot be added after a repeated parameter
- Parameter name argument must be a Symbol. Got %{name_class}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/45def4eb2bafcd28.
Report an issue: GitHub.