puppetlabs/puppet · error · Puppet::ParseError

() can only be called using the 4.x function API. See…

Error message

%{name}() can only be called using the 4.x function API. See Scope#call_function

What it means

A function that is only implemented via the 4.x function API was invoked through the 3.x function API; Error.is4x signals the caller must use Scope#call_function instead.

Solutions

  1. Invoke the function via scope.call_function('name', args) from Ruby
  2. Call it directly from the Puppet language
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at lib/puppet/parser/functions.rb:321 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/8ede20136b8f375a. Report an issue: GitHub.

Appendix: source

Thrown at lib/puppet/parser/functions.rb:321

  class << self
    private

    def merged_functions(environment)
      root = environment_module(Puppet.lookup(:root_environment))
      env = environment_module(environment)

      root.all_function_info.merge(env.all_function_info)
    end

    def get_function(name, environment)
      environment_module(environment).get_function_info(name.intern) || environment_module(Puppet.lookup(:root_environment)).get_function_info(name.intern)
    end
  end

  class Error
    def self.is4x(name)
      raise Puppet::ParseError, _("%{name}() can only be called using the 4.x function API. See Scope#call_function") % { name: name }
    end
  end
end

View on GitHub (pinned to e227c27540)