puppetlabs/puppet · error · ArgumentError
The code loaded from %{source_ref} produced function with th
Error message
The code loaded from %{source_ref} produced function with the wrong name, expected %{expected}, actual %{actual} What it means
Error "The code loaded from %{source_ref} produced function with the wrong name, expected %{expected}, actual %{actual}" thrown in puppetlabs/puppet.
Source
Thrown at lib/puppet/pops/loader/puppet_function_instantiator.rb:42
# Only one function is allowed (and no other definitions)
case result.definitions.size
when 0
raise ArgumentError, _("The code loaded from %{source_ref} does not define the function '%{func_name}' - it is empty.") % { source_ref: source_ref, func_name: typed_name.name }
when 1
# ok
else
raise ArgumentError, _("The code loaded from %{source_ref} must contain only the function '%{type_name}' - it has additional definitions.") % { source_ref: source_ref, type_name: typed_name.name }
end
the_function_definition = result.definitions[0]
unless the_function_definition.is_a?(Model::FunctionDefinition)
raise ArgumentError, _("The code loaded from %{source_ref} does not define the function '%{type_name}' - no function found.") % { source_ref: source_ref, type_name: typed_name.name }
end
unless the_function_definition.name == typed_name.name
expected = typed_name.name
actual = the_function_definition.name
raise ArgumentError, _("The code loaded from %{source_ref} produced function with the wrong name, expected %{expected}, actual %{actual}") % { source_ref: source_ref, expected: expected, actual: actual }
end
unless result.body == the_function_definition
raise ArgumentError, _("The code loaded from %{source} contains additional logic - can only contain the function %{name}") % { source: source_ref, name: typed_name.name }
end
# Adapt the function definition with loader - this is used from logic contained in it body to find the
# loader to use when making calls to the new function API. Such logic have a hard time finding the closure (where
# the loader is known - hence this mechanism
private_loader = loader.private_loader
Adapters::LoaderAdapter.adapt(the_function_definition).loader_name = private_loader.loader_name
# Cannot bind loaded functions to global scope, that must be done without binding that scope as
# loaders survive a compilation.
closure_scope = nil # Puppet.lookup(:global_scope) { {} }
created = create_function_class(the_function_definition)
# create the function instance - it needs closure (scope), and loader (i.e. where it should start searching for things
# when calling functions etc.View on GitHub (pinned to e227c27540)
When it happens
Trigger: Thrown at lib/puppet/pops/loader/puppet_function_instantiator.rb:42 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/2620f9ff8212f8b4.
Report an issue: GitHub.