puppetlabs/puppet · error · Puppet::ParseError

Please supply a parameter to perform a Hiera lookup

Error message

Please supply a parameter to perform a Hiera lookup

What it means

HieraPuppet.parse_args normalizes puppet's two calling conventions (manifest calls combine positional args into one array; template calls spread them) and raises Puppet::ParseError when the normalized list is empty. It means a hiera-family function was invoked with no key argument at all.

Source

Thrown at lib/hiera_puppet.rb:43

    #   hiera("foo", "bar")
    #
    # Are invoked internally after combining the positional arguments into a
    # single array:
    #
    #   func = function_hiera
    #   func(["foo", "bar"])
    #
    # Functions called from templates preserve the positional arguments:
    #
    #   scope.function_hiera("foo", "bar")
    #
    # Deal with Puppet's special calling mechanism here.
    if args[0].is_a?(Array)
      args = args[0]
    end

    if args.empty?
      raise Puppet::ParseError, _("Please supply a parameter to perform a Hiera lookup")
    end

    key      = args[0]
    default  = args[1]
    override = args[2]

    [key, default, override]
  end

  def hiera
    @hiera ||= Hiera.new(:config => hiera_config)
  end

  def hiera_config
    config = {}

    config_file = hiera_config_file
    if config_file

View on GitHub (pinned to e227c27540)

Solutions

  1. Pass at least the key: hiera('mykey') or hiera('mykey', 'default')
  2. If the key is computed, guard the empty case before invoking the function
  3. Migrate to lookup(), which has clearer argument diagnostics

Example fix

# before
scope.function_hiera([])

# after
scope.function_hiera(['mykey'])
Defensive patterns

Strategy: validation

Validate before calling

def safe_hiera(scope, args)
  args = args[0] if args.size == 1 && args[0].is_a?(Array)
  raise ArgumentError, 'hiera key required' if args.nil? || args.empty?
  scope.function_hiera(args)
end

Prevention

When it happens

Trigger: Writing hiera() with an empty argument list, calling scope.function_hiera([]) from an ERB template, or dynamically building a function call whose arguments array ends up empty after flattening.

Common situations: Template code computing the key name programmatically and passing an empty array; refactors that drop the key argument; copy-paste from documentation leaving the key out.

Related errors


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