{"record":{"id":"6c39c21a4a3d11d1","repo":"puppetlabs/puppet","slug":"please-supply-a-parameter-to-perform-a-hiera-looku","errorCode":null,"errorMessage":"Please supply a parameter to perform a Hiera lookup","messagePattern":"Please supply a parameter to perform a Hiera lookup","errorType":"validation","errorClass":"Puppet::ParseError","httpStatus":null,"severity":"error","filePath":"lib/hiera_puppet.rb","lineNumber":43,"sourceCode":"    #   hiera(\"foo\", \"bar\")\n    #\n    # Are invoked internally after combining the positional arguments into a\n    # single array:\n    #\n    #   func = function_hiera\n    #   func([\"foo\", \"bar\"])\n    #\n    # Functions called from templates preserve the positional arguments:\n    #\n    #   scope.function_hiera(\"foo\", \"bar\")\n    #\n    # Deal with Puppet's special calling mechanism here.\n    if args[0].is_a?(Array)\n      args = args[0]\n    end\n\n    if args.empty?\n      raise Puppet::ParseError, _(\"Please supply a parameter to perform a Hiera lookup\")\n    end\n\n    key      = args[0]\n    default  = args[1]\n    override = args[2]\n\n    [key, default, override]\n  end\n\n  def hiera\n    @hiera ||= Hiera.new(:config => hiera_config)\n  end\n\n  def hiera_config\n    config = {}\n\n    config_file = hiera_config_file\n    if config_file","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/hiera_puppet.rb#L25-L61","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass at least the key: hiera('mykey') or hiera('mykey', 'default')","If the key is computed, guard the empty case before invoking the function","Migrate to lookup(), which has clearer argument diagnostics"],"exampleFix":"# before\nscope.function_hiera([])\n\n# after\nscope.function_hiera(['mykey'])","handlingStrategy":"validation","validationCode":"def safe_hiera(scope, args)\n  args = args[0] if args.size == 1 && args[0].is_a?(Array)\n  raise ArgumentError, 'hiera key required' if args.nil? || args.empty?\n  scope.function_hiera(args)\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard template-driven function calls with an empty-args check before invoking","Prefer lookup() with named arguments in new code — misuse fails with clearer diagnostics","Static-check templates that interpolate function calls with computed argument lists"],"tags":["hiera","function-call","arguments","puppet"],"backgroundTag":"missing-function-argument","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}